none
What happens after InsertOnSubmit RRS feed

  • Question

  • Hi i have lets say this:

    Code Snippet

    book dbbook = (book)newBook;

    dc.books.InsertOnSubmit(dbbook);

     

     

    being book my entity class and dc my datacontext i want to know if, after calling dc.SubmitChanges(), my entity class have a brand new ID property value (the one of @@IDENTITY)? being this autoincremented in DB, i want to use the newly inserted ID on a table not related to my book table thanks

     

     

    Thursday, November 27, 2008 6:41 PM

Answers

  •  

    Yes - LINQ to SQL is aware of autogenerated fields like identity columns and will retrieve the value after SubmitChanges and populate your entity's pkey property.
    Friday, November 28, 2008 3:40 PM

All replies

  •  

    Yes - LINQ to SQL is aware of autogenerated fields like identity columns and will retrieve the value after SubmitChanges and populate your entity's pkey property.
    Friday, November 28, 2008 3:40 PM
  • But after insert, i want to retrieve the new ID from identity column. What can I do ?
    Thursday, July 2, 2009 1:57 PM