Updating multiple tables with LinqToSql in one unit of work

Posted by zsharp on Stack Overflow See other posts from Stack Overflow or by zsharp
Published on 2009-09-28T04:41:22Z Indexed on 2010/03/21 21:01 UTC
Read the original article Hit count: 312

Table 1: int ID-a(pk)

Table 2: int ID-a(pk), int ID-b(pk)

Table 3: int ID-b(pk), string C

I have the data to insert into Table 1. But I do not have the ID-a, which is autogenerated. I have many string C to insert in Table 3.

I am trying to insert row into Table 1, get the ID-a to insert in Table 2 along with the ID-b that is auto-Generated in Table 3 when I submit each string C, all in one submission to db.

Right now I am calling dc.SubmitChanges twice in same call. Is it efficient to have to submit changes twice on same DataContext or can this be combined further?

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about database-design