I have this LINQ Query to calculate the revenue sum of each employee
(from E in db.Employees
orderby E.EmployeeID
select new
{
E.EmployeeID,
E.FirstName,
E.LastName,
TotalSales =
(from O in E.Orders
from D in O.Order_Details
let LineTotal = (D.UnitPrice * D.Quantity)
select LineTotal).Sum()
}).ToList()But, once I factor in the "discount" to become
D.UnitPrice * D.Quantity * (1-D.Discount)
it will hit error "linq to entities does not recognize the method
system.decimal to decimal method" or "casting to decimal is not supported in LINQ to entities queries" even when I tried to do some conversion and casting.
This is the data type for these properties:
- decimal UnitPrice
- short Quantity
- float Discount
Any work around for this?