//MS SQL requires specific isolation mode for transactional load/update to work correctly without deadlocks public override IsolationLevel GetIsolationLevel(LinqCommandFlags flags) { if (flags.IsSet(LinqCommandFlags.WriteLock)) { return(IsolationLevel.ReadCommitted); } else if (flags.IsSet(LinqCommandFlags.ReadLock)) { return(IsolationLevel.Snapshot); } else { return(IsolationLevel.Unspecified); } }
//we need to check if we require transaction (if we are setting LOCK) private DataConnection GetLinqCommandConnection(EntitySession session, LinqCommandFlags flags) { var conn = GetConnection(session); if (conn.DbTransaction == null && flags.IsSet(LinqCommandFlags.ReadLock | LinqCommandFlags.WriteLock)) { //We need to start transaction with proper isolation level. We also need to associate connection with session, // so it will stay there and will be reused for all coming operations if (conn.Lifetime < ConnectionLifetime.Transaction) { conn.Lifetime = ConnectionLifetime.Transaction; } session.CurrentConnection = conn; var isoLevel = _driver.GetIsolationLevel(flags); conn.BeginTransaction(commitOnSave: true, isolationLevel: isoLevel); } return(conn); }
//we need to check if we require transaction (if we are setting LOCK) private DataConnection GetLinqCommandConnection(EntitySession session, LinqCommandFlags flags) { var conn = GetConnection(session); if (conn.DbTransaction == null && flags.IsSet(LinqCommandFlags.ReadLock | LinqCommandFlags.WriteLock)) { //We need to start transaction with proper isolation level. We also need to associate connection with session, // so it will stay there and will be reused for all coming operations if (conn.Lifetime < ConnectionLifetime.Transaction) conn.Lifetime = ConnectionLifetime.Transaction; session.CurrentConnection = conn; var isoLevel = _driver.GetIsolationLevel(flags); conn.BeginTransaction(commitOnSave: true, isolationLevel: isoLevel); } return conn; }
//MS SQL requires specific isolation mode for transactional load/update to work correctly without deadlocks public override IsolationLevel GetIsolationLevel(LinqCommandFlags flags) { if (flags.IsSet(LinqCommandFlags.WriteLock)) return IsolationLevel.ReadCommitted; else if (flags.IsSet(LinqCommandFlags.ReadLock)) return IsolationLevel.Snapshot; else return IsolationLevel.Unspecified; }