I have an html table that is displaying customer orders. One of these columns is a sub total which needs to add all rows for sub total in the order details table for that specific order. Is there a way to do this within my anonymous type?
Here’s some images of what I’m talking about:


And the code i’m using minus the total amount addition:
var q = db.Orders.Where(x => x.siteUserID == 41)
.OrderByDescending(x => x.orderID)
.Select(x => new
{
dateCreated = x.dateCreated,
orderID = x.orderID,
count = x.OrderDetails.Count()
});
Currently I’ve created a class with identical properties of my LINQ query, and am adding the results to a List and within the list calling a function that adds up the sub total.
If it could be done within my original query it would be much cleaner.
I was looking for
Sumsubtotal = x.OrderDetails.Sum(t=> t.subTotal)