Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 linq to sql 进行插入后,如果我的表有标识列,我可以取回 Identity_scope 值吗?
SubmitChangesLinq to SQL 为您完成这项工作,它在调用该方法后立即可用的标识值。
SubmitChanges
var entity = new Entity(); // ... ctx.Entities.InsertOnSubmit(entity); ctx.SubmitChanges(); // Here you can use the generated value of yout identity column entity.Id;