This project has moved. For the latest updates, please go here.

Mechanism to return Identity Column?

Aug 26, 2014 at 6:38 PM
What is the best method of returning the identity value of the rows that have just been bulk inserted?

I'm trying to bulk insert some nested classes that rely on the parent class for an ID. For now I'm inserting the parents, querying the database and then mapping the nested table/class using a separate unique ID to find the new identity value.

In an ideal world i'd have an option for the BulkInsert to update the existing entities on insert.

Please let me know your thoughts and thanks for the library!
Aug 28, 2014 at 8:30 AM
Hi,

I make a bypass to resolve this problem, I'm working with SQL Server 2012, and I can use SEQUENCES. I dropped my IDENTITY columns and I created INT NOT NULL columns. I fill those columns with my SQL Sequence.

It's good performance because I only have two requests, the first to get my sequence range, and the second to fill my Pocos before BulkInsert.

If anyone has a better idea?

Thanks!