views:

312

answers:

1

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?

+1  A: 

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?

keithwarren7
There are no triggers on the tables,no join.Its a simple insert.I was wondering if there is a case where a delete operatin take place before insert provided table has no triggers.Is it related to transaction coz on the db,under transaction,thr is one delete statement and after that insert statement
Kapilg