tags:

views:

31

answers:

2

I want to return the PK ID when I insert a new user via linq to sql.

how can I do this? i.e. is there anything built in or do I have to do 2 queries?

+3  A: 

You don't have to do anything. Just check the PK field on the object you used to create it after you've done a SubmitChanges(). LINQ to SQL autopopulates it.

Nissan Fan
A: 

If you have a DB-generated ID field then it will be enough to set the Auto Generated Value property to True and the AutoSync property to OnInsert for this field in the model designer.

Devart