Пример #1
0
        protected override Expression VisitCommand(DbCommandExpression command)
        {
            if (this.linguist.Language.AllowsMultipleCommands || !IsMultipleCommands(command))
            {
                return(this.BuildExecuteCommand(command));
            }

            return(base.VisitCommand(command));
        }
Пример #2
0
        protected virtual bool IsMultipleCommands(DbCommandExpression command)
        {
            if (command == null)
            {
                return(false);
            }

            switch ((DbExpressionType)command.NodeType)
            {
            case DbExpressionType.Insert:
            case DbExpressionType.Delete:
            case DbExpressionType.Update: return(false);

            default: return(true);
            }
        }
Пример #3
0
        protected virtual Expression VisitCommand(DbCommandExpression command)
        {
            switch ((DbExpressionType)command.NodeType)
            {
            case DbExpressionType.Insert: return(this.VisitInsert(command as DbInsertCommand));

            case DbExpressionType.Update: return(this.VisitUpdate(command as DbUpdateCommand));

            case DbExpressionType.Delete: return(this.VisitDelete(command as DbDeleteCommand));

            case DbExpressionType.If: return(this.VisitIf(command as DbIFCommand));

            case DbExpressionType.Block: return(this.VisitBlock(command as DbBlockCommand));

            case DbExpressionType.Declaration: return(this.VisitDeclaration(command as DbDeclarationCommand));

            default:
            {
                return(this.VisitUnknown(command));
            }
            }
        }
Пример #4
0
        protected virtual Expression BuildExecuteCommand(DbCommandExpression command)
        {
            var expression  = this.Parameterize(command);
            var commandText = this.linguist.Format(expression);
            var namedValues = DbNamedValueGatherer.Gather(expression);
            var qc          = new QueryCommand(commandText, namedValues.Select(v => new QueryParameter(v.Name, v.Type, v.QueryType)));
            var values      = namedValues.Select(v => Expression.Convert(this.Visit(v.Value), typeof(object))).ToArray() as Expression[];

            var projection = ProjectionFinder.FindProjection(expression);

            if (projection != null)
            {
                return(this.ExecuteProjection(projection, false, qc, values, isTopLevel: true));
            }

            var plan = Expression.Call
                       (
                this.executor, nameof(QueryExecutor.ExecuteCommand), null,
                Expression.Constant(qc),
                Expression.NewArrayInit(typeof(object), values)
                       );

            return(plan);
        }
        protected override Expression VisitCommand(DbCommandExpression command)
        {
            this.isTopLevel = true;

            return(base.VisitCommand(command));
        }
Пример #6
0
 protected virtual Expression VisitCommand(DbCommandExpression command)
 {
     this.Write(this.FormatQuery(command)); return(command);
 }