This is a migrated thread and some comments may be shown as answers.

Get Identity column value

3 Answers 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FISCAL
Top achievements
Rank 1
FISCAL asked on 20 May 2010, 10:33 AM
Hi,

Is it possible to get the Identity column value once the record is inserted into the table successfully?

Thanks.

M G

3 Answers, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 21 May 2010, 04:56 PM
Hi M G,

After you call scope.Transaction.Commit() (or .SaveChanges() in case you are using the new context approach) the identity column values are automatically populated with the new values. You can directly access them.
Hope this helps.

All the best,
Serge
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gaurav
Top achievements
Rank 1
answered on 21 Mar 2012, 07:36 AM
i am not using transaction for adding new enitity.
i am using ria service for communication.
after i add new object to entity through entitymodel new value of identity column not populated in that new object.

is there any settings we need to do for that ????

please help me
0
PetarP
Telerik team
answered on 23 Mar 2012, 02:51 PM
Hello Gaurav,

 No there shouldn't be any additional steps you need to do. Can you please look into the generated sql after you call context.SaveChanges and check if you get an select scope_identity() statement generated at the end of your insert query? If you are having that indeed appended can you please mark your primary key with the [Key] attribute inside your model.

Kind regards,
Petar
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
General Discussions
Asked by
FISCAL
Top achievements
Rank 1
Answers by
Serge
Telerik team
Gaurav
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or