[英]how to use Foreign key in L2E or EF when needs insert?
您需要將對象掛在其圖形中,然后調用保存更改。 ObjectContext負責其余的工作。
Customer customer = myObjectContext.Single(c => c.Name == "Bob");
//new up an Order instance that has never been in the database.
Order order = GetOrderForCar();
//Add order to the Orders ObjectSet of a Customer
// This connects order to our ObjectContext.
customer.Orders.Add(order);
myObjectContext.SaveChanges();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.