Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
        //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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public virtual System.Data.IsolationLevel GetIsolationLevel(LinqCommandFlags flags)
 {
     return System.Data.IsolationLevel.Unspecified;
 }
Exemplo n.º 9
0
 //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;
 }
Exemplo n.º 10
0
 public static bool IsSet(this LinqCommandFlags flags, LinqCommandFlags flag)
 {
     return((flags & flag) != 0);
 }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
0
 public virtual System.Data.IsolationLevel GetIsolationLevel(LinqCommandFlags flags)
 {
     return(System.Data.IsolationLevel.Unspecified);
 }