2011-12-27 73 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