Ejemplo n.º 1
0
 protected BatchExpression UpdateBatch(BatchExpression batch, Expression input, LambdaExpression operation, Expression batchSize, Expression stream)
 {
     if ((((input != batch.Input) || (operation != batch.Operation)) || (batchSize != batch.BatchSize)) || (stream != batch.Stream))
     {
         return(new BatchExpression(input, operation, batchSize, stream));
     }
     return(batch);
 }
Ejemplo n.º 2
0
        protected virtual Expression VisitBatch(BatchExpression batch)
        {
            LambdaExpression operation = (LambdaExpression)this.Visit(batch.Operation);
            Expression       batchSize = this.Visit(batch.BatchSize);
            Expression       stream    = this.Visit(batch.Stream);

            return(this.UpdateBatch(batch, batch.Input, operation, batchSize, stream));
        }
Ejemplo n.º 3
0
        protected override Expression VisitBatch(BatchExpression batch)
        {
            if (!(!this.linguist.Language.AllowsMultipleCommands && this.IsMultipleCommands(batch.Operation.Body as CommandExpression)))
            {
                return(this.BuildExecuteBatch(batch));
            }
            Expression       expression  = this.Visit(batch.Input);
            LambdaExpression expression3 = Expression.Lambda(this.Visit(batch.Operation.Body), new ParameterExpression[] { batch.Operation.Parameters[1] });

            return(Expression.Call(base.GetType(), "Batch", new Type[] { King.Framework.Linq.TypeHelper.GetElementType(expression.Type), batch.Operation.Body.Type }, new Expression[] { expression, expression3, batch.Stream }));
        }
Ejemplo n.º 4
0
 protected virtual Expression VisitBatch(BatchExpression batch)
 {
     base.Write("Batch(");
     base.WriteLine(ExpressionWriter.Indentation.Inner);
     this.Visit(batch.Input);
     base.Write(",");
     base.WriteLine(ExpressionWriter.Indentation.Same);
     this.Visit(batch.Operation);
     base.Write(",");
     base.WriteLine(ExpressionWriter.Indentation.Same);
     this.Visit(batch.BatchSize);
     base.Write(", ");
     this.Visit(batch.Stream);
     base.WriteLine(ExpressionWriter.Indentation.Outer);
     base.Write(")");
     return(batch);
 }
Ejemplo n.º 5
0
        protected virtual Expression BuildExecuteBatch(BatchExpression batch)
        {
            Expression expression  = this.Parameterize(batch.Operation.Body);
            string     commandText = this.linguist.Format(expression);
            ReadOnlyCollection <NamedValueExpression> onlys = NamedValueGatherer.Gather(expression);
            QueryCommand command = new QueryCommand(commandText, from v in onlys select new QueryParameter(v.Name, v.Type, v.QueryType));

            Expression[]         initializers = (from v in onlys select Expression.Convert(this.Visit(v.Value), typeof(object))).ToArray <UnaryExpression>();
            Expression           expression2  = Expression.Call(typeof(Enumerable), "Select", new Type[] { batch.Operation.Parameters[1].Type, typeof(object[]) }, new Expression[] { batch.Input, Expression.Lambda(Expression.NewArrayInit(typeof(object), initializers), new ParameterExpression[] { batch.Operation.Parameters[1] }) });
            ProjectionExpression expression4  = ProjectionFinder.FindProjection(expression);

            if (expression4 != null)
            {
                Scope scope = this.scope;
                ParameterExpression fieldReader = Expression.Parameter(typeof(FieldReader), "r" + this.nReaders++);
                this.scope = new Scope(this.scope, fieldReader, expression4.Select.Alias, expression4.Select.Columns);
                LambdaExpression expression6 = Expression.Lambda(this.Visit(expression4.Projector), new ParameterExpression[] { fieldReader });
                this.scope = scope;
                MappingEntity entity = EntityFinder.Find(expression4.Projector);
                command = new QueryCommand(command.CommandText, command.Parameters);
                return(Expression.Call(this.executor, "ExecuteBatch", new Type[] { expression6.Body.Type }, new Expression[] { Expression.Constant(command), expression2, expression6, Expression.Constant(entity, typeof(MappingEntity)), batch.BatchSize, batch.Stream }));
            }
            return(Expression.Call(this.executor, "ExecuteBatch", (Type[])null, new Expression[] { Expression.Constant(command), expression2, batch.BatchSize, batch.Stream }));
        }
 protected virtual bool CompareBatch(BatchExpression x, BatchExpression y)
 {
     return(((this.Compare(x.Input, y.Input) && this.Compare(x.Operation, y.Operation)) && this.Compare(x.BatchSize, y.BatchSize)) && this.Compare(x.Stream, y.Stream));
 }