Can't 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
10:27 UTC
Read the original article
Hit count: 286
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
I've also tried this in VS2010 with a standard drag and drop data context and same thing.
Thanks in advance
© Stack Overflow or respective owner