O
Olivier.Paesbrugghe
I'm having a problem with a Linq statement.
I made a console application that makes use of Northwind database.
Made a dbml file of the database whith the designer and now I want to
see the total of all orders of the customers.
I used this statement:
var custTotalOrders = db.Customers
.Select( p =>
new { c.ContactName,
TotalOrders = c.Orders.Sum( o => o.Order_Details.Sum( od =>
od.Quantity * od.UnitPrice))});
(Un)fortunately there is 1 client who hasn't made any orders yet and
so I get an error:
Unhandled Exception: System.InvalidOperationException: The null value
cannot be
assigned to a member with type System.Decimal which is a non-nullable
value type.
Is there something wrong with my expression or is this an error due to
the fact LINQ is still in beta?
kind regards,
Olivier
I made a console application that makes use of Northwind database.
Made a dbml file of the database whith the designer and now I want to
see the total of all orders of the customers.
I used this statement:
var custTotalOrders = db.Customers
.Select( p =>
new { c.ContactName,
TotalOrders = c.Orders.Sum( o => o.Order_Details.Sum( od =>
od.Quantity * od.UnitPrice))});
(Un)fortunately there is 1 client who hasn't made any orders yet and
so I get an error:
Unhandled Exception: System.InvalidOperationException: The null value
cannot be
assigned to a member with type System.Decimal which is a non-nullable
value type.
Is there something wrong with my expression or is this an error due to
the fact LINQ is still in beta?
kind regards,
Olivier