Accessing columns using Dynamic Linq

c#-4.0 datarow datatable dynamic-linq linq

Question

I have been trying to create a dynamic query that will check the contents of a datatable. The thing is I the number columns to be selected and also there names are given at runtime. The where clause thus needs to be constructed dynamically. Is there any way to do this in Dynamic linq?

I started with a small eg

string query = "Field<string>(@0)=@1";
            fsrch = GetValues();
var result = CapacityTable.AsEnumerable().AsQueryable().Where(query);

I also tried

            var result = CapacityTable.AsEnumerable().AsQueryable().Where("Location = @1","Chennai");

In both cases I get an error saying DataRow does not have the specified property. How do I access the columns of the table dynamically????

1
1
10/22/2011 10:24:59 AM

Popular Answer

Check out the Dynamic LINQ blog written by Scott Gu.

1
10/22/2011 12:41:55 PM


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