none
LINQ Join Question RRS feed

  • Question

  • Hello,

    I am grouping my data in order calculate a sum for responder count.   One of my data fields is an XML data type so I can't use in the group by.   After grouping is it possible to join to the class that contains my XML data?   Or is there a better way to accomplish this so I can get the ChartSpecs into MyDataPoint object?

                // Use the tempPoints data to group by ChartId, etc. in order to sum the Responder Count
                dataPoints = (from i in
    	                            (from tp in tempPoints
    		                         select new {tp.ChartId, tp.ChartTypeId, tp.QId, tp.QuestionText, tp.Answer, tp.ResponderCnt, tp.ChartSpecs}
                                     )
    		                            group i by new {i.ChartId, i.ChartTypeId, i.QId, i.QuestionText, i.Answer} into g
    		                            select new MyDataPoint
    		                            {
    			                            ChartId = g.Key.ChartId, 
    			                            QId = g.Key.QId,
                                                           ChartTypeId = g.Key.ChartTypeId,
    			                            QuestionText = g.Key.QuestionText,
    			                            Answer = g.Key.Answer,
    			                            Cnt = g.Sum(dp => dp.ResponderCnt)
    		                            }
    	                     ).ToList();
    
    Tuesday, October 13, 2009 8:28 PM

Answers

  • figured it out.  added the join right before the select new My DataPoint line.
    • Marked as answer by JasonRP Tuesday, October 13, 2009 9:10 PM
    Tuesday, October 13, 2009 9:10 PM