Can get Sum() working in Northwind example
        Posted  
        
            by Vince
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Vince
        
        
        
        Published on 2010-04-30T08:14:57Z
        Indexed on 
            2010/04/30
            8:17 UTC
        
        
        Read the original article
        Hit count: 218
        
Hi,
The following code is generating a runtime error and I have no idea why.
from o in Orders
group o by o.Employee into employeeOrders
select new {
    employeeOrders.Key.EmployeeID,
    employeeOrders.Key.FirstName,
    Orders = 
        from eord in employeeOrders
        orderby eord.OrderID
        select new {
            eord.OrderID,
            eord.OrderDate,
            OrderTotal=eord.OrderDetails.Sum (od => od.UnitPrice)
        }
}
The error is
Member access 'System.Decimal UnitPrice' of 'LINQPad.User.OrderDetails' not legal on type 'LINQPad.User.Orders
Thanks in advance
© Stack Overflow or respective owner