How to get id values for multiple rows inserted in a table?

I am using LINQ 2 SQL. When a record is inserted, the identity key on the table is created. I am inserting multiple records via LINQ 2 SQL. How can I get their Id values back after the insert is done?

Comments

  • LINQ-to-SQL automatically populates the identity values, so it's simply a matter of checking the entities that you inserted after calling SubmitChanges().

  • Thanks for the suggestion. I will have to think of some way since in an OLTP system, I am getting millions of records inserted every hour.