user1627768
user1627768

Reputation: 3

Insert to multiple tables from the same view using LINQ to SQL

I've just designed my database in SQL Server 2008 and now that I'm starting the actual implementation I have the following concern: I have a view (an aspx page) which submits a student registering to an institute. This page insert is related to about 3 tables (student/parents and address). How can i insert the details collected to the 3 tables simultaneously using linq to sql?

Upvotes: 0

Views: 160

Answers (1)

djsumdog
djsumdog

Reputation: 2706

You would have three insert statements. If you need them to all fail or succeeded, put them in a transaction.

using (var transaction = new TransactionScope())
{
  try
  {
    //insert statements

    transaction.Complete();
  }
}

Upvotes: 1

Related Questions