I am trying to write a linq query which would give me this type of result
So I am trying to Group by order type which could be Surplus or Deficit. After that I am Grouping by Region and then I want to see how much of deficit of each masstype is there. So far I have achieved this
var results = Order.GetActive().GroupBy(x => x.OrderType).
Select(i => new { OrderType = i.Key, Orders = i.ToList().GroupBy(j => j.GetLocation().Region) });
Now I am stuck in trying to group it by masstype and then calculate total amount. For example if there are 10 surplus orders for masstype1 I want to show one entry accumulating the amount.
Something like this
{
'Region'{
'Oslo'{
'Masstype' {
'Rock' {
'Defict', 100
'Surplus', 0
},
'Mud' {
'Defict', 100
'Surplus', 100
}
}
}
}
}
