Help needed to write a LINQ with GROUP bY(C#3.0)
Posted
by Newbie
on Stack Overflow
See other posts from Stack Overflow
or by Newbie
Published on 2010-05-10T02:32:48Z
Indexed on
2010/05/10
2:38 UTC
Read the original article
Hit count: 211
c#3.0
I have a datatable whose structure is as under
Week Dates Key_Factors Factor_Values
--- ----- ----------- -------------
1 29/12/2000 Factor_1 19.20
1 29/12/2000 Factor_2 20.67
1 29/12/2000 Factor_3 10
2 21/12/2007 Factor_1 20.54
2 21/12/2007 Factor_4 21.70
I have a Object model like
WeekNumber(int)
Dates(Datetime)
FactorDictionary (Dictionary<string,double>)
I am trying to populate the data from DataTable to my Object Model whose needed output is as under
Desired Output
----------------
WeekNumber : 1
Dates : 29/12/2000
FactorDictionary:
Key_Factors: Factor_1 Factor_Values:19.20
Key_Factors: Factor_2 Factor_Values:20.67
Key_Factors: Factor_3 Factor_Values:10
WeekNumber : 2
Dates : 21/12/2007
FactorDictionary:
Key_Factors: Factor_1 Factor_Values:20.54
Key_Factors: Factor_4 Factor_Values:21.70
i.e. The result is grouped by weeks.
Can I achieve the same by using LINQ.
I am using C#(3.0) with framework(3.5)
Thanks
© Stack Overflow or respective owner