I have a good LINQ query that is working well, it returns a result set, each result set inherits from MyBase.
I need to substitute AbcTransport by doing a kind of loop through of collection of strings I have. These strings are actually the object names (classes)
MyBase testItem = from x in AbcTransport
from y in x.SolidItems
where y.Classified == otherObject.Classified
select x;
This will cut down on the amount of code I need to write.
I think this is possible with Dynamic Linq, but I am unsure where to start.
Imagine I have currently about 26 objects like AbcTransport that are all named different but all inherit from MyBase. The property I am interested in is actually on MyBase. If I could do a kind of Loop using Dynamic linq I wouldn’t have to write my query 26 times and also would make in maintainable as when I add more objects I only have to add the object name into my collection and that’s it.
Why not put that query inside a generic method?
You could call it like this: