4
我做了一個使用linq到sql的插入後,如果我的表有一個標識列,我可以得到Identity_scope值嗎?Linq to Sql:插入後可以返回Identity_Scope嗎?
我做了一個使用linq到sql的插入後,如果我的表有一個標識列,我可以得到Identity_scope值嗎?Linq to Sql:插入後可以返回Identity_Scope嗎?
Linq 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;
這是明顯的方式來看:)謝謝。 – Jeremy 2009-11-13 06:03:37