I use this dynamic LINQ library together with Linq-to-Entities.
I build query and after that iterate it with foreach(object e in query){}
query=db.Table1.Where("it.FieldA>10").Select("it.FieldB");
works.
query=db.Table1.Where(e=>e.FieldA>10).GroupBy("it.FieldB", "it").Select("key")
works.
But query=db.Table1.Where("it.FieldA>10").GroupBy("it.FieldB", "it").Select("key")
causes EntitySqlException
with message The query syntax is not valid., near keyword 'FROM', line 2, column 1.
in line with foreach
statement.
How can I make it work without exception ?
Note that type of db.Table1.Where(e=>e.FieldA>10)
is IQueryable<Table1>
, but type of db.Table1.Where("it.FieldA>10")
is System.Data.Objects.ObjectQuery<Table1>
.