How to use LINQ with dynamic collections
So long as data
is an IEnumerable
of some kind, you can use:
var a = ((IEnumerable) data).Cast<dynamic>()
.Where(p => p.verified);
The Cast<dynamic>()
is to end up with an IEnumerable<dynamic>
so that the type of the parameter to the lambda expression is also dynamic
.
Try casting to IEnumerable<dynamic>
((IEnumerable<dynamic>)data).Where(d => d.Id == 1);
This approach is 4x faster than other approachs.
good luck