It depends...you could do an inefficient query by parsing the list of names one time; searching on each one and then caching your own AF Paths to the objects. Then you only do a bulk "AFElement.FindElementsByPath".
Otherwise, it depends on your list, how big you expect it to be, whether it is user entered etc. If you're looking for multiple Units, for example, then you can use the name filter syntax to do that...
var elementsFound = AFElement.FindElements(db, null, "Unit ", OSIsoft.AF.AFSearchField.Name, true, OSIsoft.AF.AFSortField.Name, OSIsoft.AF.AFSortOrder.Ascending, 10000);
"Unit " would find "Unit 1", "Unit 2", "Unit 3", "Unit 4" and "Unit 5". In a single call, rather than supplying those 5 names in a list.
Really depends on how your list of names is built.
Thank you for the input. The AF search looks very interesting.
I have tried the following search operation:
List<AFSearchToken> tokens = elementNames.Select(name => new AFSearchToken(AFSearchFilter.Name, AFSearchOperator.Equal, name)).ToList();
var afElementSearch = new AFElementSearch(afDatabase, "", tokens);
Unfortunately, it always returns only one element, which there are more elements.
Is it because I have multiple tokens with AFSearchFilter.Name? I would like to use an OR-statement between the several tokens.