Updating multiple tables with LINQ and ASP.NET MVC

Just quick, I'm just looking for a little clarification.

I want to update multiple tables from a single Create action before I try it, I'm just wondering if I can just do the following:

db.hdCalls.InsertOnSubmit(a)
db.hdCustomers.InsertOnSubmit(b)
db.hdAssign.InsertOnSubmit(c)
db.SubmitChanges()

      

Or is it a little more complicated than that?

+2


source to share


2 answers


Yes, SubmitChanges will then trigger 3 inserts.



+4


source


Small question even if this post is old.

What if one of the inserts fails, will all other inserts be canceled? Because if one of them doesn't work, then I don't want any of the other inserts to be committed.



How is this handled?

+1


source







All Articles