4

使用 linq to sql 进行插入后,如果我的表有标识列,我可以取回 Identity_scope 值吗?

4

1 回答 1

6

SubmitChangesLinq to SQL 为您完成这项工作,它在调用该方法后立即可用的标识值。

var entity = new Entity();
// ...
ctx.Entities.InsertOnSubmit(entity);
ctx.SubmitChanges();
// Here you can use the generated value of yout identity column

entity.Id;
于 2009-11-13T05:03:00.100 回答