public class ConvertedReading
{
public int DatePointID { get; set; }
public string DatapointName { get; set; }
public DateTime ReadingDate { get; set; }
public double Value { get; set; }
}
Given a collection below:
IEnumerable<ConvertedReading> readingData;
using c# , write a LINQ statment using lambda syntax to output a collection of the following:
public class DataPointTotal
{
public string DatapointName{get; set;}
public double Total{get; set;}
}
one item should be returned per datepointID
Total should reprenst the sum of convertedReading.valye relevent to each datePointID
I have tried with the following, nit quite shre if it works, i cant seems to get the sum of value right.
var subtotals = from x in ConvertedReading group x by x.DatapointName into g select new { Type = x.DatapointName , SubTotal = g.Sum(x => x.Total) };
Is the syntax correct?
Thanks guys,