System.Linq.Dynamic.Core icon indicating copy to clipboard operation
System.Linq.Dynamic.Core copied to clipboard

group by on joined structure does not work

Open ameapps opened this issue 4 years ago • 2 comments

I wrote some code making a join (using the library) between two tables from data context exporting the result columns as object fields. EXAMPLE:

tableA = { field1 = "", field2 = ""}
tableB = { field1 = "", field2 = ""}
var join = { tableAfield1 = "", tableAfield2 = "", tableBfield1 = "", tableBfield2 = ""}

When I try to group the obtained IQueryable collection by a selector (for example "tableBfield1"), I get the following exception: "client-side group by is not supported".

I tried to convert the IQueryable collection to a List<Dictionary<string, object>> and I could run the group by using the library! My problem is that I can't get the data in the process but I need to keep working on the IQueryable as I need to compose a dynamic query based on a request JSON file. I need to just make my expression tree richer and richer.

Then, I tried to cast the joined collection object type to a dynamically defined type, having the same column names and types) using the method "OfType()", but it does not work. What I mean is that I could not translate IQueryable to IQueryable<DynamicType> using that method.

So in these days I've been wondering about the following questions: • Is there a way to export a join IQueryable collection of a given type? • Is there a way to cast my join collection of an anonymous object to a type? • do i need to compose my own expression tree to make the group by work on IQueryable?

Thanks for helping guys!

ameapps avatar Dec 18 '21 00:12 ameapps

Hello @stefanoyoyo,

Can you please provide a full working example which describes this issue?

StefH avatar Dec 18 '21 09:12 StefH

Hello @stefanoyoyo,

Can you please provide a full working example which describes this issue?

StefH avatar Feb 22 '23 17:02 StefH