Ejemplo n.º 1
0
 protected override Expression VisitCommand(CommandExpression command)
 {
     if (!(!this.linguist.Language.AllowsMultipleCommands && this.IsMultipleCommands(command)))
     {
         return(this.BuildExecuteCommand(command));
     }
     return(base.VisitCommand(command));
 }
Ejemplo n.º 2
0
 protected virtual bool IsMultipleCommands(CommandExpression command)
 {
     if (command == null)
     {
         return(false);
     }
     switch (command.NodeType)
     {
     case ((ExpressionType)0x3fa):
     case ((ExpressionType)0x3fb):
     case ((ExpressionType)0x3fc):
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        protected virtual Expression BuildExecuteCommand(CommandExpression command)
        {
            Expression expression  = this.Parameterize(command);
            string     commandText = this.linguist.Format(expression);
            ReadOnlyCollection <NamedValueExpression> onlys = NamedValueGatherer.Gather(expression);
            QueryCommand command2 = new QueryCommand(commandText, from v in onlys select new QueryParameter(v.Name, v.Type, v.QueryType));

            Expression[]         values     = (from v in onlys select Expression.Convert(this.Visit(v.Value), typeof(object))).ToArray <UnaryExpression>();
            ProjectionExpression projection = ProjectionFinder.FindProjection(expression);

            if (projection != null)
            {
                return(this.ExecuteProjection(projection, false, command2, values));
            }
            return(Expression.Call(this.executor, "ExecuteCommand", (Type[])null, new Expression[] { Expression.Constant(command2), Expression.NewArrayInit(typeof(object), values) }));
        }
Ejemplo n.º 4
0
        public override Expression GetInsertExpression(MappingEntity entity, Expression instance, LambdaExpression selector)
        {
            if (this.mapping.GetTables(entity).Count < 2)
            {
                return(base.GetInsertExpression(entity, instance, selector));
            }
            List <Expression> commands = new List <Expression>();
            Dictionary <string, List <MemberInfo> > dependentGeneratedColumns = this.GetDependentGeneratedColumns(entity);
            Dictionary <MemberInfo, Expression>     map = new Dictionary <MemberInfo, Expression>();

            using (IEnumerator <MappingTable> enumerator = this.GetDependencyOrderedTables(entity).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    List <MemberInfo> list3;
                    Func <MappingEntity, MemberInfo, bool> fnIncludeColumn = null;
                    MappingTable    table      = enumerator.Current;
                    TableAlias      alias      = new TableAlias();
                    TableExpression expression = new TableExpression(alias, entity, this.mapping.GetTableName(table));
                    if (fnIncludeColumn == null)
                    {
                        fnIncludeColumn = (e, m) => (this.mapping.GetAlias(e, m) == this.mapping.GetAlias(table)) && !this.mapping.IsGenerated(e, m);
                    }
                    IEnumerable <ColumnAssignment> assignments = this.GetColumnAssignments(expression, instance, entity, fnIncludeColumn, map).Concat <ColumnAssignment>(this.GetRelatedColumnAssignments(expression, entity, table, map));
                    commands.Add(new InsertCommand(expression, assignments));
                    if (dependentGeneratedColumns.TryGetValue(this.mapping.GetAlias(table), out list3))
                    {
                        CommandExpression item = this.GetDependentGeneratedVariableDeclaration(entity, table, list3, instance, map);
                        commands.Add(item);
                    }
                }
            }
            if (selector != null)
            {
                commands.Add(this.GetInsertResult(entity, instance, selector, map));
            }
            return(new BlockCommand(commands));
        }
Ejemplo n.º 5
0
        protected virtual Expression VisitCommand(CommandExpression command)
        {
            switch (command.NodeType)
            {
            case ((ExpressionType)0x3fa):
                return(this.VisitInsert((InsertCommand)command));

            case ((ExpressionType)0x3fb):
                return(this.VisitUpdate((UpdateCommand)command));

            case ((ExpressionType)0x3fc):
                return(this.VisitDelete((DeleteCommand)command));

            case ((ExpressionType)0x3ff):
                return(this.VisitBlock((BlockCommand)command));

            case ((ExpressionType)0x400):
                return(this.VisitIf((IFCommand)command));

            case ((ExpressionType)0x401):
                return(this.VisitDeclaration((DeclarationCommand)command));
            }
            return(this.VisitUnknown(command));
        }
Ejemplo n.º 6
0
 protected virtual Expression VisitCommand(CommandExpression command)
 {
     base.Write(this.FormatQuery(command));
     return(command);
 }
 protected override Expression VisitCommand(CommandExpression command)
 {
     this.isTopLevel = true;
     return(base.VisitCommand(command));
 }