Alex Rivera | Logout

How do I build up LINQ dynamically

Asked 2009-08-18T08:12:59.750
9

I have a scenario where I have custom configured column names, associated operators like < > = between etc. and then a value associated.

I'm trying to determine if it is possible to build up a LINQ query with a dynamic (string) where clause?

I've noticed the Predicate.OR Preditcate.AND stuff, but that is not quite what I'm talking about.

Any suggestions?

Edit
Report

1 Answer

8

Actually, there is a specific library from Microsoft (System.Linq.Dynamic) that comes with the C# VS2008 samples that supports this. Get it from here (Microsoft Download)

The library is included in the \LinqSamples\DynamicQuery directory of the samples of above download.

For extensive usage examples check this page: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

answered 2009-08-18T08:18:07.570

Your Answer