Get Last Inserted row Id in Linq to SQL

Get Last Inserted row Id in Linq to SQL

Hello Everyone, I am going to share the code sample to get the last Inserted row id using Linq to SQL as given below.

//The Asp.Net code sample to get Last Inserted row Id in Linq to SQL. i.e.

private long AddAccountAddress(AccountAddress accountAddress, long AccountID, long AddressID)
    accountAddress.AddressID = AddressID;
    accountAddress.AccountID = AccountID;
    accountAddress.CreatedBy = 0;
    accountAddress.CreatedDate = DateTime.Now;
    accountAddress.IsActive = true;
    accountAddress.IsDeleted = false;

   //The Last Inserted AccountAddressID is from accountAddresses object.
   long AccountAddressID = accountAddress.AccountAddressID;
   return AccountAddressID;

Thank you!

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment Powered by Blogger.
ASK Questions