Filtering collection of PDMS objects in .NET/C#

 
  • Hi all

    Basically, I have question - where can I get manual/information for database filters ?
    E.g. If I want to collect all equipment form database, I could do

    TypeFilter Tpfilter = new TypeFilter(DbElementTypeInstance.EQUI);
    DBElementCollection Dbcoll = new DBElementCollection(CurrentElement.Element, Tpfilter);


    I could add more types, and it is clear, but how to invert the filter?
    If I need everything except some types?
  • You may try to use other Filters like:
    var dataFilter = new AndFilter(new BaseFilter[]
                                                  {
                                                      new AttributeValueFilter(DbAttributeInstance.TYPE, TestOperator.NotEquals, "EQUIPMENT")
                                                  });
    DBElementCollection dec = new DBElementCollection(ele, dataFilter);
  • Hi !

    Another solution:


    TypeFilter typeFilter = new TypeFilter();
    typeFilter.Add(DbElementType.GetAllElementTypes());
    typeFilter.Remove(DbElementTypeInstance.EQUIPMENT);

    DBElementCollection dBElementCollection = new DBElementCollection(CurrentElement.Element, typeFilter);


    I don't know which is the more efficient.
    It would be interesting to compare.
  • [URL="https://www.avevaworldforum.com/member.php?31083-L">L, thanks for the tips.

    I have checked both and both are working, but as I want to include different types or exclude different types dynamically, I come up to following solution:

                   List