I’m all for quick and easy examples especially when it comes to LINQ, so here goes one that I get asked a lot. This is a quick example that shows how to grab a few properties from a parent entity and use an aggregate function on the parent entity’s children entities. Specifically, this example grabs the OrderID and OrderDate from the Orders entity and then calculates the order total for each order. The sum is calculated by summing the UnitPrice * Quantity in the OrderDetails entity.
Notice the grouping of the orders first. Then the Orders are joined back to the result so we can get the OrderDate property. Then the projection pulls out the Key (the OrderID), the OrderDate, and calculates the OrderTotal using an aggregate and a lambda expression.
Hopefully this will shed some light on this type of projection with LINQ for some.