Kapil
Kapil

Reputation: 9969

Is using TransactionScope causing delete statements againist the database?

I am using LINQ to SQl and using TransactionScopre I am inserting the data in SQL .

_context.tblDataContainer.InsertOnSubmit(migrationData);

using (TransactionScope ts = new TransactionScope())
{
    _context.SubmitChanges();
    ts.Complete();
}

doing this, does linq execute any delete statements on SQL. i have checked using context log and no delete statement is issued to database but my db admin says that i am executing some delete statements in this transaction. Any views on this?

Upvotes: 1

Views: 499

Answers (1)

keithwarren7
keithwarren7

Reputation: 14278

We would really need to know more about your schema. Remember that L2S is declarative - you are declare what you want done not how to do it. It is entirely possible that the L2S engine looked at your database, found some type of constraint or other situation and decided that the best way to safely insert that data would be to first delete a record. While this is a stretch, it could happen.

HOWEVER, there are other possibilities, such as triggers. Did you check the table are doing an insert on and see if there are any triggers on it that may be deleting data elsewhere?

Upvotes: 1

Related Questions