4

Possible Duplicate:
Building Dynamic LINQ Queries based on Combobox Value

I am using LINQ within C# to connect to a DBML relationship. Currently, all of my queries have been static (from x in table select x.item), however now I have built a pseudo adhoc report system for my client. The client can pick some items from a box and filter. When the user submit the filtered data, I am storing everything in a custom object. The object holds the table name, table item name, constraint (>, <, +, contains, etc), and the text to filter on. I gather all of these attributes into an object and I need to be able to query off of it. For example, my filtered object could come back as the following:

tblCars, strCarType, =, "Ford"

My application has a central table that needs to join to each one of the tables that comes in after the filtration, and then query on that data to get the results. What is the best approach to dynamically build the LINQ query with the joins?

Community
  • 1
  • 1
EvanGWatkins
  • 1,427
  • 6
  • 23
  • 52
  • 1
    Do you need to use LINQ? It might be better to go with an older method that can handle this more smoothly. – Servy Apr 24 '12 at 15:17
  • 2
    I think [this](http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx) excellent article from Scott Guthrie might help. – dan radu Apr 24 '12 at 15:20
  • Another good link to consider: http://blogs.msdn.com/b/vbteam/archive/2007/08/29/implementing-dynamic-searching-using-linq.aspx – Dejan Janjušević Apr 25 '12 at 10:54
  • I'd go with a datatable for this one. – Stilgar Apr 25 '12 at 10:56

0 Answers0