What is the best way to make a dynamic linq to entities query?

c# dynamic-data dynamic-linq linq-to-entities

Question

Now this is probably really easy but being the tool that I am, I'm not sure the best way to attack this problem.

I have a DAL and a load of methods using EF that populate drop down lists in a UI. i.e. material, source.

From these, I want the user to populate a gridview with the product data based upon their criteria they select i.e. they could select something from ddlMaterial and something from ddlSource, or nothing from ddlMaterial and something from ddlSource, etc, etc.

How would I go about creating the linq for this?

Is it a case of writing a load of if, and/or statements or is there something a bit more clever I can do - I suspect the latter but being a noob, I need a push in the right direction.

Any help or points in the right direction gratefully received.

1
1
7/20/2010 9:29:02 AM

Accepted Answer

If you want to get really dynamic try looking at system.linq.dynamic

You can download the dll here

1
7/20/2010 9:57:23 AM

Popular Answer

Check out PredicateBuilder, it can be used to generate predicates that can be used to query your DAL.



Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow