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
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
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 to
System.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
EntitySQL, or can identify any good reason for moving to
Expression Trees I'd really appreciate it.
We are using Dynamic Linq extensively in our project... Its clean and it works well, but its very complicated if you would want to peep into or change anything its code.
One of the problems what I found using a combination of Dynamic Linq and EF 6 is EF 6 uses query caching to perform faster retrieval of data and the way where query that is built in Dynamic Linq does not use this feature of EF 6. So we have to change the where to use query caching.
This is just a small example to say Dynamic Linq is not meant for newer EF versions. Dynamic Linq is a wonderful solution if you want to work with un-typed collection like IQuerable, but its very difficult to maintain.
I am hoping you would work in a typed environment(IQueryable). Otherwise essentially you would need to modify Dynamic Linq to really take advantage of EF 6.