I have seen quite a few ways to get dynamic LINQ to work for the .GroupBy
, but every one that I see seems to expect a hard coded entity. I want to reproduce the following as dynamic LINQ:
//need dynamic LINQ for this
var groupedRows = rows.GroupBy(z => new { make = z["make"], model = z["model"] })
.Select(x => x.Key);
I'd like to be able to just do this, making the entire function a string:
var groupedRows = rows.GroupBy(z => "new { make = z[\"make\"], model = z[\"model\"] }")
I realize that if it were only a regular entity, I could do this
mylist.GroupBy(z => new { make = z.make, model = z.model }).Select(x => x.Key);
If I had that regular entity, I could use Mitsu's dynamic GroupByMany.
I am trying to get this to work with a regular datatable (not strongly typed). Any ideas?