public LinqCommandInfo(LinqCommand command, QueryOptions options, LinqCommandFlags flags, List<Type> entityTypes, string cacheKey, List<ParameterExpression> externalParameters, List<LambdaExpression> includes) { CommandType = command.CommandType; CommandKind = command.Kind; Options = options; Flags = flags; EntityTypes = entityTypes; CacheKey = cacheKey; ExternalParameters = externalParameters; Includes = includes; }
public LinqCommandInfo(LinqCommand command, QueryOptions options, LinqCommandFlags flags, List <Type> entityTypes, string cacheKey, List <ParameterExpression> externalParameters, List <LambdaExpression> includes) { CommandType = command.CommandType; CommandKind = command.Kind; Options = options; Flags = flags; EntityTypes = entityTypes; CacheKey = cacheKey; ExternalParameters = externalParameters; Includes = includes; }
public TranslatedLinqCommand(string sqlTemplate, string sql, IList<LinqCommandParameter> parameters, LinqCommandFlags flags, Func<IDataRecord, EntitySession, object> objectMaterializer = null, QueryResultsProcessor resultsPostProcessor = null, Func<IList> resultListCreator = null) { BatchSqlTemplate = sqlTemplate; Sql = sql; Parameters = parameters; Flags = flags; ObjectMaterializer = objectMaterializer; ResultsPostProcessor = resultsPostProcessor; ResultListCreator = resultListCreator; }
//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); } }
public TranslatedLinqCommand(string sqlTemplate, string sql, IList <LinqCommandParameter> parameters, LinqCommandFlags flags, Func <IDataRecord, EntitySession, object> objectMaterializer = null, QueryResultsProcessor resultsPostProcessor = null, Func <IList> resultListCreator = null) { BatchSqlTemplate = sqlTemplate; Sql = sql; Parameters = parameters; Flags = flags; ObjectMaterializer = objectMaterializer; ResultsPostProcessor = resultsPostProcessor; ResultListCreator = resultListCreator; }
//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); }
private ValueKind AnalyzeConstant(ConstantExpression constNode) { AddCacheKey(constNode.Value); if (constNode.Value == null) { return(ValueKind.Constant); } //entity set var entQuery = constNode.Value as EntityQuery; if (entQuery != null) { _entityTypes.Add(entQuery.ElementType); var lockTarget = constNode.Value as ILockTarget; if (lockTarget != null) { if (lockTarget.LockOptions.IsSet(LockOptions.ForUpdate)) { _flags |= LinqCommandFlags.WriteLock; } if (lockTarget.LockOptions.IsSet(LockOptions.SharedRead)) { _flags |= LinqCommandFlags.ReadLock; } if (lockTarget.LockOptions.IsSet(LockOptions.NoLock)) { _flags |= LinqCommandFlags.NoLock; } } return(ValueKind.Db); } if (!constNode.Type.IsValueTypeOrString()) { return(ValueKind.Local); } return(ValueKind.Constant); }
public virtual System.Data.IsolationLevel GetIsolationLevel(LinqCommandFlags flags) { return System.Data.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; }
public static bool IsSet(this LinqCommandFlags flags, LinqCommandFlags flag) { return((flags & flag) != 0); }
//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; }
public virtual System.Data.IsolationLevel GetIsolationLevel(LinqCommandFlags flags) { return(System.Data.IsolationLevel.Unspecified); }