日期:2014-05-17 浏览次数:21142 次
public class Order
{
public virtual Guid OrderID {get;set;}
public virtual ICollection<Menu> Menus {get;set;}
}
public class Menu
{
public virtual Guid MenuID {get;set;}
public virtual ICollection<Order> Orders {get;set;}
public virtual int Price {get;set;}
}
Order order = new Order();
order.OrderID = Guid.NewGuid();
//How to create?
//order.Menus = new List<Menu>();
order.Menus.Add(menu1);
order.Menus.Add(menu2);
order.Menus.Add(menu3);
order.Menus.Add(menu4);
dataContext.Orders.Add(order);
dataContext.SaveChanges();