开发者

Using IList in Entityframework 4.1

开发者 https://www.devze.com 2023-03-12 21:27 出处:网络
I have this code where all objects are created by Entity Framework 4.1: public void UpdateCustomer(int CustomerID, IList<O开发者_如何学Gorder> CustomerOrders)

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消