Does dynamic GroupBy in dynamic LINQ work with dynamic Where?

.net dynamic dynamic-linq linq linq-to-entities

Question

This LINQ dynamic library is used in conjunction with Linq-to-Entities.
I construct the query and then iterate it usingforeach(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 using messageThe query syntax is not valid., near keyword 'FROM', line 2, column 1. in keepingforeach statement.

How can I get it to operate flawlessly?

Observe that kind ofdb.Table1.Where(e=>e.FieldA>10) is IQueryable<Table1> nevertheless, kind ofdb.Table1.Where("it.FieldA>10") is System.Data.Objects.ObjectQuery<Table1> .

1
0
1/5/2012 4:52:33 PM

Accepted Answer

located it,db.Table1.AsQueryable() altered it, sodb.Table1.AsQueryable().Where("it.FieldA>10").GroupBy("it.FieldB", "it").Select("key") consistently effective

Microsoft Dynamic Linq library expands, which was the issue.IQueryable<Table1> as a result, it has no impact on ObjectQuery<Table1> which kind is it thatdb.Table1 .

0
8/9/2010 5:22:09 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