Using IList in Entityframework 4.1
I have this code where all objects are created by Entity Framework 4.1:
public void UpdateCustomer(int CustomerID, IList<O开发者_如何学Gorder> CustomerOrders)
{
foreach (var OrderItem in CustomerOrders)
{
Customer.Order = OrderItem;
}
}
When I try to assign OrderItem
to Customer.Order
, I receive the following error:
Error 15 Cannot implicitly convert type 'Order' to 'System.Data.Objects.DataClasses.EntityCollection'
What am I doing wrong here, and how can this be fixed?
You should assign collection of orders not an order
foreach (var OrderItem in CustomerOrders)
Customer.Order.Add(OrderItem);
精彩评论