The Dynamic LINQ library let you execute query with dynamic string and provide some utilities methods such as ParseLambda , Parse , and CreateClass .
You can use LINQ to query any enumerable collections such as List<T>, Array, or Dictionary<TKey,TValue>. The collection may be user-defined or may be returned by a . NET API.
The Dynamic LINQ library exposes a set of extension methods on IQueryable corresponding to the standard LINQ methods at Queryable, and which accept strings in a special syntax instead of expression trees.
Instead of using language operators or type-safe lambda extension methods to construct your LINQ queries, the dynamic query library provides you with string-based extension methods that you can pass any string expression into.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With