1
Vote

Audit statements get included within Transaction

description

I am actually performing some bulk import and thus used transaction with LINQ to perform inserts. As I am performing intensive insert operations, many (around 780,000) audit records get generated.
This actually results in my transaction to timeout. If there any flag to turn off auditing when using transaction scope with LINQ?

using (new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }))
{
//Your db Operation (Submit Changes etc...)
}

comments

dodone wrote Apr 21, 2010 at 11:26 AM

do ont put the objects to audit in the DefaultAuditDefinitions(); but change
public MyDataContext(bool toAudit):this()
{
  if (toAudit)
 {
     AttachedAuditObjects();
  }
}

private void AttachedAuditObjects()
{
 //TO put the objects to audit here
}

So that, for any time, when you will just retrieve data but make no changes to them, you can use new MyDataContext(false); and in your situation, also use this constructor.