After I do an insert using linq to sql, can I get the Identity_scope value back if my table has an identity column?
Asked
Active
Viewed 1,038 times
1 Answers
6
Linq to SQL does the job for you, the identity value it's available just after the SubmitChanges
method is called.
var entity = new Entity();
// ...
ctx.Entities.InsertOnSubmit(entity);
ctx.SubmitChanges();
// Here you can use the generated value of yout identity column
entity.Id;

Christian C. Salvadó
- 807,428
- 183
- 922
- 838
-
It was way to obvious for me to see :) Thanks. – Jeremy Nov 13 '09 at 06:03