Beispiel #1
0
        protected virtual Expression VisitCommand(CommandExpression command)
        {
            switch ((DbExpressionType)command.NodeType)
            {
            case DbExpressionType.Insert:
                return(VisitInsert((InsertCommand)command));

            case DbExpressionType.Update:
                return(VisitUpdate((UpdateCommand)command));

            case DbExpressionType.Delete:
                return(VisitDelete((DeleteCommand)command));

            case DbExpressionType.If:
                return(VisitIf((IFCommand)command));

            case DbExpressionType.Block:
                return(VisitBlock((BlockCommand)command));

            case DbExpressionType.Declaration:
                return(VisitDeclaration((DeclarationCommand)command));

            default:
                return(VisitUnknown(command));
            }
        }
Beispiel #2
0
 protected override Expression VisitCommand(CommandExpression command)
 {
     if (linguist.Language.AllowsMultipleCommands || !IsMultipleCommands(command))
     {
         return(BuildExecuteCommand(command));
     }
     else
     {
         return(base.VisitCommand(command));
     }
 }
Beispiel #3
0
        protected virtual bool IsMultipleCommands(CommandExpression command)
        {
            if (command == null)
            {
                return(false);
            }
            switch ((DbExpressionType)command.NodeType)
            {
            case DbExpressionType.Insert:
            case DbExpressionType.Delete:
            case DbExpressionType.Update:
                return(false);

            default:
                return(true);
            }
        }
Beispiel #4
0
        protected virtual Expression BuildExecuteCommand(CommandExpression command)
        {
            // parameterize query
            Expression expression = Parameterize(command);

            string commandText = linguist.Format(expression);
            ReadOnlyCollection <NamedValueExpression> namedValues = NamedValueGatherer.Gather(expression);
            var qc = new QueryCommand(commandText, namedValues.Select(v => new QueryParameter(v.Name, v.Type, v.QueryType)));

            Expression[] values = namedValues.Select(v => Expression.Convert(Visit(v.Value), typeof(object))).ToArray();

            ProjectionExpression projection = ProjectionFinder.FindProjection(expression);

            if (projection != null)
            {
                return(ExecuteProjection(projection, false, qc, values));
            }

            Expression plan = Expression.Call(executor, "ExecuteCommand", null, Expression.Constant(qc), Expression.NewArrayInit(typeof(object), values));

            return(plan);
        }
 protected override Expression VisitCommand(CommandExpression command)
 {
     isTopLevel = true;
     return(base.VisitCommand(command));
 }
Beispiel #6
0
 protected virtual Expression VisitCommand(CommandExpression command)
 {
     Write(FormatQuery(command));
     return(command);
 }