2011-12-27 45 views

回答

2

是的,當您撥打SubmitChanges時,Id屬性會自動設置。例如:

var customer = new Customer(); 
Console.WriteLine(customer.Id); // 0 

context.Customers.InsertOnSubmit(customer); // Attach it to the context 
context.SubmitChanges(); 

Console.WriteLine(customer.Id); // 1