Creating dynamic linq queries
Linq, introduced with .NET Framework 4.5 is one of the best .NET developer friend. But have you ever think about creating dynamic queries with linq ? It can be sometimes useful if you have to inject dynamic expressions to your queries, for example let's say you have to write a query but need to resolve the field names at runtime because it depends on some rules defined in some configuration places. Good news, there is a nuget package for this task ! Here is Linq.Dynamic , it allows to create linq queries such as : var query = db.Customers . Where( "City = @0 and Orders.Count >= @1" , "London" , 10). OrderBy ( " CompanyName " ). Select( "new( CompanyName as Name, Phone)" ); And many other features with this package... ;)