コード例 #1
0
        protected virtual Expression BuildExecuteCommand(CommandExpression command)
        {
            // parameterize query
            var expression = this.Parameterize(command);

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

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

            ProjectionExpression projection = ProjectionFinder.FindProjection(expression);

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

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

            return(plan);
        }
コード例 #2
0
 protected override Expression VisitCommand(CommandExpression command)
 {
     if (this.linguist.Language.AllowsMultipleCommands || !IsMultipleCommands(command))
     {
         return(this.BuildExecuteCommand(command));
     }
     else
     {
         return(base.VisitCommand(command));
     }
 }
コード例 #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);
            }
        }
コード例 #4
0
 protected override Expression VisitCommand(CommandExpression command)
 {
     this.isTopLevel = true;
     return(base.VisitCommand(command));
 }