Hi Dojo,
What is the most performant way to retrieve all elements for a certain protocol?
Engine
var elements = engine.FindElementsByProtocol("protocol name", "protocol version");
Class Library
var dms = engine.GetDms();
var protocol = dms.GetProtocol("protocol name", "protocol version");
var elements = dms.GetElements().Where(x => x.Protocol == protocol);
HI Jens,
For now, I would say the Engine call.
Why? The class library could be made better.
proposed change 1: do not retrieve the protocol if you already have the input.
var dms = engine.GetDms();
var protocolName = "protocolName";
var elements = dms.GetElements().Where(x => String.Equals(protocolName, x?.Name, StringComparison.InvariantCultureIgnoreCase);
proposed change 2:
pass filter in the GetElements() method, like an "predicate<Element> filter" or something. The result must be a list of Elements which matches the filter.
Leaving the filter empty/null results in having the full list of elements.
I do highly believe that if those 2 proposed changes are active on the field, then I would say to use the class library.
Hope this helps you further.
Hi Jens, if performance is critical for you I would suggest using the engine.FindElementsByProtocol as it is using the GetLiteElementInfo SLNET Message in the background.
Right now, IDms is using multiple SLNET messages (GetInfo + GetElementByIDMessage) for this. Note that the GetProtocol call would also imply requesting more information than needed (GetProtocolMessage).
Kind Regards,
Jarno