AnsweredAssumed Answered

Is it possible to get a list of elements not using a template?

Question asked by SvenBatalla on Jul 15, 2015
Latest reply on Jul 22, 2015 by Karl.Hodgkiss

In our application, we create elements of a specific type based on a base AFElementTemplate.  When we wish to see all elements of our type, it is a very simple query to PIAF to get that list because the query is simply to get all elements of a certain template type.  For reference, I mean the following code:

 

AFElementTemplate baseTemplate = db.ElementTemplates["AppTemplate"];
var elements = AFElement.FindElementsByTemplate(... baseTemplate ...);

 

As you can probably tell from the code above, we also utilize base templates.  So really our template structure is derived and looks similar to what you see below (this is examples):

 

  • AppTemplate
    • AppTemplate-Digital
      • AppTemplate-Digital-Sampled
    • AppTemplate-Numeric
      • AppTemplate-Numeric-Metered
      • AppTemplate-Numeric-Sampled

 

The good thing about the original call I highlighted is that I can get all elements that are derived from that root template.  So getting the elements of a certain type is easy.  My issue now is that I need to get all the OTHER types of elements.  Any other element in the PIAF hierarchy is eligible to be a parent element to my elements.  So I need a list of them for my UI.  Right now I'm forced to get a list of all elements in the entire system, then remove elements from the result that are of my type.  This is not ideal at all; more-so when we think that there may be tens of thousands of elements in the hierarchy.  I also want to avoid having to give these elements templates because the user can (and will want to) control what kind of elements those things are (e.g. pumps, wells, etc.).

 

Does anyone have any ideas how I can get a list of all elements that are NOT derived from a certain template?

Outcomes