English 中文(简体)
Linq to Sql: Can I return the Identity_Scope after an insert?
原标题:

After I do an insert using linq to sql, can I get the Identity_scope value back if my table has an identity column?

最佳回答

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;
问题回答

暂无回答




相关问题
LINQ to SQL as databinding source for WPF Treeview

I wonder if someone could provide a simple example of the following. (preferably in VB.Net): I have an SQL database with related tables and I am successfully using LINQ to SQL in other areas of my ...

Linq to SQL insert/select foreign/primary records

I have table A and Table B. Table B contains two columns, Name and ID. Table A contains several columns and a foreign key column pointing to B.ID called B_ID On the client side, I have all the data I ...

LINQ to SQL Dynamic Sort question

How do I code the Select clause in my LINQ satament to select column aliases so I can sort on them basically I want to accomplish this SQL statement in LINQ: select type_id as id, ...

Using a schema other than dbo in LinqToSql Designer

Is there a way to specify in a data connection or the LinqToSql Designer a schema? Whenever I go to setup a data connection for LinqToSql there doesn t seem to be anyway to specify a schema and I ...

热门标签