I have a list of EQModel.
public class EQModel
{
public string IncEpicentre { get; set; }
public decimal MagnitudeInMl { get; set; }
public int TotalHits { get; set; }
}
I would like to group this list for different locations and also by different ranges of MagnitudesInMl value.
Ranges of : { 5, 6,7,8 }
I am able to group them separately using LINQ but am unable to group using both IncEpicenter and MagnitudeInMl.
For grouping by range, I used:
var ranges = new[] { 5, 6,7,8 };
var lsGrouped = lsEQData.GroupBy(x => ranges.FirstOrDefault(r => r > x.MagnitudeInMl))
.Select(g => new { g.Key, TotalHits = g.Count().ToString()});
For IncEpicenter,
var lsCount = lsEQData.GroupBy(x => x.IncEpicentre)
.Select(g => new { g.Key, TotalHits = g.Count().ToString() });
Now, I would like to group the list by both.
Any help would be highly appreciated.