4
How can I use interval grouping with Linq?
var dados = new[] {
new { Id = 0, dias=100, preco= 25, Nome="etc"},
new { Id = 1, dias=40, preco= 50, Nome="etc1"},
new { Id = 2, dias=50, preco= 55, Nome="etc2"},
new { Id = 3, dias=80, preco= 70, Nome="etc3"},
new { Id = 4, dias=150, preco= 90, Nome="etc4"},
new { Id = 5, dias=420, preco= 100, Nome="etc5"},
new { Id = 6, dias=122, preco= 500, Nome="etc6"},
};
Using Linq how can I return a list with the sum of prices grouped for a range of days.
31 to 60;
61 to 90;
91 to 120;
121 to 150;
and greater than 150;
Only missed for conditions is <= instead of <; Replaced Todictionary with Select.
– Cleidson_eng