Пример #1
0
 protected virtual void SetParameterValues(QueryCommand query, DbCommand command, object[] paramValues)
 {
     if (query.Parameters.Count > 0 && command.Parameters.Count == 0)
     {
         for (int i = 0, n = query.Parameters.Count; i < n; i++)
         {
             this.AddParameter(command, query.Parameters[i], paramValues != null ? paramValues[i] : null);
         }
     }
     else if (paramValues != null)
     {
         for (int i = 0, n = command.Parameters.Count; i < n; i++)
         {
             DbParameter p = command.Parameters[i];
             if (p.Direction == System.Data.ParameterDirection.Input ||
                 p.Direction == System.Data.ParameterDirection.InputOutput)
             {
                 p.Value = paramValues[i] ?? DBNull.Value;
             }
         }
     }
 }
Пример #2
0
 public override IEnumerable <T> Execute <T>(QueryCommand command, Func <FieldReader, T> fnProjector, MappingEntity entity, object[] paramValues)
 {
     this.LogCommand(command, paramValues);
     this.StartUsingConnection();
     try
     {
         DbCommand    cmd    = this.GetCommand(command, paramValues);
         DbDataReader reader = this.ExecuteReader(cmd);
         var          result = Project(reader, fnProjector, entity, true);
         if (this.provider.ActionOpenedConnection)
         {
             result = result.ToList();
         }
         else
         {
             result = new EnumerateOnce <T>(result);
         }
         return(result);
     }
     finally
     {
         this.StopUsingConnection();
     }
 }
        private Expression ExecuteProjection(ProjectionExpression projection, bool okayToDefer, QueryCommand command, Expression[] values)
        {
            okayToDefer &= (this.receivingMember != null && this.policy.IsDeferLoaded(this.receivingMember));

            var saveScope = this.scope;
            ParameterExpression reader = Expression.Parameter(typeof(FieldReader), "r" + nReaders++);

            this.scope = new Scope(this.scope, reader, projection.Select.Alias, projection.Select.Columns);
            LambdaExpression projector = Expression.Lambda(this.Visit(projection.Projector), reader);

            this.scope = saveScope;

            var entity = EntityFinder.Find(projection.Projector);

            string methExecute = okayToDefer
                ? "ExecuteDeferred"
                : "Execute";

            // call low-level execute directly on supplied DbQueryProvider
            Expression result = Expression.Call(this.executor, methExecute, new Type[] { projector.Body.Type },
                                                Expression.Constant(command),
                                                projector,
                                                Expression.Constant(entity, typeof(MappingEntity)),
                                                Expression.NewArrayInit(typeof(object), values)
                                                );

            if (projection.Aggregator != null)
            {
                // apply aggregator
                result = DbExpressionReplacer.Replace(projection.Aggregator.Body, projection.Aggregator.Parameters[0], result);
            }
            return(result);
        }
Пример #4
0
 public override int ExecuteCommand(QueryCommand query, object[] paramValues)
 {
     return(this.executor.ExecuteCommand(query, paramValues));
 }
Пример #5
0
 public override IEnumerable <T> ExecuteDeferred <T>(QueryCommand query, Func <FieldReader, T> fnProjector, MappingEntity entity, object[] paramValues)
 {
     return(this.executor.ExecuteDeferred <T>(query, Wrap(fnProjector, entity), entity, paramValues));
 }
Пример #6
0
 public override IEnumerable <T> ExecuteBatch <T>(QueryCommand query, IEnumerable <object[]> paramSets, Func <FieldReader, T> fnProjector, MappingEntity entity, int batchSize, bool stream)
 {
     return(this.executor.ExecuteBatch <T>(query, paramSets, Wrap(fnProjector, entity), entity, batchSize, stream));
 }
Пример #7
0
 public override IEnumerable <int> ExecuteBatch(QueryCommand query, IEnumerable <object[]> paramSets, int batchSize, bool stream)
 {
     return(this.executor.ExecuteBatch(query, paramSets, batchSize, stream));
 }
Пример #8
0
 public abstract int ExecuteCommand(QueryCommand query, object[] paramValues);
Пример #9
0
 public abstract IEnumerable <T> ExecuteDeferred <T>(QueryCommand query, Func <FieldReader, T> fnProjector, MappingEntity entity, object[] paramValues);
Пример #10
0
 public abstract IEnumerable <T> ExecuteBatch <T>(QueryCommand query, IEnumerable <object[]> paramSets, Func <FieldReader, T> fnProjector, MappingEntity entity, int batchSize, bool stream);
Пример #11
0
 public abstract IEnumerable <int> ExecuteBatch(QueryCommand query, IEnumerable <object[]> paramSets, int batchSize, bool stream);