Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Group by three common fields and create a single row

$
0
0
I have a three a data in var as shown below

    Apparea   code   Category   Notes  Date
    Eng        23     IND       Note1  Date1
    French     44     UK        Note2  Date2
    German     23     US        Note3  Date2
    Eng        23     IND       Note2  Date4
    Uk-eng     55     IND       Note5  Date5
    Franch     44     UK        Note   Date

I just want a single row which has same Apparea and code and category should be group together.

like

    Eng    23    IND Note1 Date1 Note2 Date4
    French 44    UK  Note2 Date2 Note Date
    German 23    US  Note3 Date3
    Uk-eng 55   IND  Note5 Date5
    


I want this to be done with LINQ or lambda.

    var resVal = ( from m in resultData
    join n in resultData on new { Area = m.FieldValues["Application_x0020_Area"].ToString(), wbs = m.FieldValues["WBS_x0020_Code"].ToString(), category = m.FieldValues["Effort_x0020_Category"].ToString() } equals new { Area = n.FieldValues["Application_x0020_Area"].ToString(), wbs = n.FieldValues["WBS_x0020_Code"].ToString(), category = n.FieldValues["Effort_x0020_Category"].ToString() }
                                          select new
                                          {
                                              Effort = m.FieldValues["Actual_x0020_Effort_x0020__x0028"].ToString(),
                                              EffortDate = m.FieldValues["Effort_x0020_Date"].ToString(),
                                              appArea = m.FieldValues["Application_x0020_Area"].ToString(),
                                              wbscode = m.FieldValues["WBS_x0020_Code"].ToString(),
                                              effCat = m.FieldValues["Effort_x0020_Category"].ToString(),
                                              notes = m.FieldValues["Task_x002f_Root_x0020_Cause"].ToString()
                                          }).Distinct().ToArray();

Please provide the solution or any other way. I just want the result to bind to a datagridview.

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>