Reputation: 79
I am new to Linq-to-SQL.
I want to retrieve the identity value from Linq-to-SQL while using DBContext.SubmitChanges()
.
Upvotes: 0
Views: 416
Reputation: 700
After you have called SubmitChanges()
you can access the id field of your object to retrieve the ID.
Upvotes: 2
Reputation: 9027
It should automatically update your record. Something like this:
Customer cust = new Customer();
cust.Company = "blah";
context.Customers.Add( cust );
context.SubmitChanges();
int NewPk = cust.Pk;
Upvotes: 3