tags:

views:

31

answers:

1

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 http://stackoverflow.com/questions/1465700/system-linq-dynamic-select-new-into-a-listt-or-any-other-enumerable

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

A: 

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

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

Ronan