开发者

Dynamic Linq GroupBy

I followed the bellow steps to solve a similar problem as described however i dont seem to be able to get the solution to work System开发者_如何学Python.LINQ.Dynamic: Select(" new (...)") into a List<T> (or any other enumerable collection of <T>)

I have even created a project so that it is the exact same as shown.

I get an error saying that "No property or field 'Fund' exists in type 'DataRow'"

I tried to get around this problem with:

IQueryable<Result> res = table1.AsEnumerable().AsQueryable()
                              .GroupBy("it[\"Fund\"]", "it")
                              .Select<Result>("new (Key as Group, Sum(Convert.ToDouble(it[\"Value\"].ToString())) as  TotalValue)");

but while this gets me past the above error i now have a problem getting the sum as the error states

Argument types do not match

Not sure where to go from here Thanks


IQueryable<Result> res = table1.AsEnumerable().AsQueryable()
                               .GroupBy("it[\"Fund\"]", "it")
                               .Select<Result>("new (Key.ToString() as Group, Sum(Convert.ToDouble(it[\"Value\"].ToString())) as TotalValue)");

That works!! - needed to do a ToString() on the key

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜