I am currently working on a large project that uses Entity Framework extensively. Part of the functionality we have implemented is dynamic querying (Filter/Sort) of the various data models based on user-supplied filters.
To achieve this I ended up using System.Linq.Dynamic
which allows me, through various means, to create string-based filters like like "SomeProperty.StartsWith(@P0)"
and so on, and then pass these strings (and attendant parameters) to the Dynamic Linq extension methods for IQueryable<T>
(Where
, etc) so that they get executed against the database and everyone is happy.
I didn't know any other way to do this at the time except for a vague notion of Expression Trees and to be honest, I just could not get my head around them - I spent several weeks poring over a decompilation of a component that used expressions to implement dynamic querying and I balked :)
Plus it felt like I was reinventing the wheel when the functionality I needed effectively was already written by far cleverer people than myself, in the
System.Linq.Dynamic
extensions.
Now the current code all works quite well as a generalised solution for filtering, sorting, etc, on any of my entities, and I'm happy enough with it however as I became more and more familiar with E.F. I started to come across things like
And I started to wonder, given that System.Linq.Dynamic
is nearly 6 years old, and hasn't really had anything done with it in that time, am I missing out on anything? or, have I missed some fundamental point?
Should I bite the bullet and move my codebase over to use
EntitySQL
? (I assume this is like the spiritual successor toSystem.Linq.Dynamic
, or am I wrong?)Or should I go back and learn how to use
Expression Trees
because they are the way of the future/all the cool kids do it, etc? I'm not a fan of change for changes sake, and I like code that works, but I am worried that at some point in the future string-based dynamic linq becomes a dead-end and I'm stuck using it.
If anyone can help to clarify the differences between System.Linq.Dynamic
and EntitySQL
, or can identify any good reason for moving to Expression Trees
I'd really appreciate it.