示例#1
0
        public override void EndElement(string endElement)
        {
            if (!"execution".Equals(endElement) && !"orderCancelled".Equals(endElement))
            {
                return;
            }
            Decimal dec1;

            this.TryGetValue("quantity", out dec1);
            if ("execution".Equals(endElement))
            {
                Decimal dec2;
                this.TryGetValue("price", out dec2);
                this._executionBuilder.Price(dec2);
                this._executionBuilder.Quantity(dec1);
            }
            else if ("orderCancelled".Equals(endElement))
            {
                this._executionBuilder.CancelledQuantity(dec1);
            }
            long longValue;

            this.TryGetValue("executionId", out longValue);
            this._executionBuilder.ExecutionId(longValue);
            this._executionBuilders.Add(this._executionBuilder);
            this._executionBuilder = new ExecutionBuilder();
        }
        public override void EndElement(string endElement)
        {
            if (!ExecutionNodeName.Equals(endElement) && !OrderCancelledNodeName.Equals(endElement))
            {
                return;
            }

            decimal quantity;

            TryGetValue(QuantityNodeName, out quantity);
            if (ExecutionNodeName.Equals(endElement))
            {
                decimal price;

                TryGetValue(PriceNodeName, out price);

                _executionBuilder.Price(price);
                _executionBuilder.Quantity(quantity);
            }
            else if (OrderCancelledNodeName.Equals(endElement))
            {
                _executionBuilder.CancelledQuantity(quantity);
            }

            long executionId;

            TryGetValue(ExecutionIdNodeName, out executionId);
            _executionBuilder.ExecutionId(executionId);
            _executionBuilders.Add(_executionBuilder);
            _executionBuilder = new ExecutionBuilder();
        }
示例#3
0
        public virtual Expression BuildExecutionPlan(Expression expression, TranslateOptions option = null)
        {
            var translator = CreateTranslator();

            translator.Options     = option;
            translator.Syntax      = TranslateScope.Current.Context.Database.Provider.GetService <ISyntaxProvider>();
            translator.Environment = (TranslateScope.Current.Context as IEntityPersistentEnvironment).Environment;

            return(ExecutionBuilder.Build(expression, e => translator.Translate(e)));
        }
示例#4
0
        public virtual Expression BuildExecutionPlan(Expression expression, Expression provider, TranslateOptions option = null)
        {
            var translator = CreateTranslator();

            translator.Options         = option;
            translator.InternalContext = TranslateScope.Current.Context;
            translator.Environment     = (TranslateScope.Current.Context as IEntityPersistentEnvironment).Environment;

            return(ExecutionBuilder.Build(expression, provider, translator));
        }
        public void ShowExecutionBuilderDialog(ExecutionBuilderViewModel vm)
        {
            if (vm == null)
            {
                throw new ArgumentNullException(nameof(vm));
            }

            var executionBuilder = new ExecutionBuilder
            {
                Owner       = Application.Current.MainWindow,
                DataContext = vm
            };

            //executionBuilder.ShowDialog();
            executionBuilder.Show();
        }
示例#6
0
        internal Expression GetExecutionPlan(Expression expression)
        {
            LambdaExpression lambda = expression as LambdaExpression;

            if (lambda != null)
            {
                expression = lambda.Body;
            }

            var translation = expression;

            translation = PartialEvaluator.Eval(expression, ExpressionHelper.CanBeEvaluatedLocally);
            translation = FunctionBinder.Bind(this, translation);
            //translation = PartialEvaluator.Eval(translation, ExpressionHelper.CanBeEvaluatedLocally);
            translation = QueryBinder.Bind(ExpressionBuilder, this, translation);


            translation = AggregateRewriter.Rewrite(Dialect, translation);
            translation = UnusedColumnRemover.Remove(translation);
            translation = RedundantColumnRemover.Remove(translation);
            translation = RedundantSubqueryRemover.Remove(translation);
            translation = RedundantJoinRemover.Remove(translation);

            var bound = RelationshipBinder.Bind(ExpressionBuilder, translation);

            if (bound != translation)
            {
                translation = bound;
                translation = RedundantColumnRemover.Remove(translation);
                translation = RedundantJoinRemover.Remove(translation);
            }
            translation = ComparisonRewriter.Rewrite(ExpressionBuilder, translation);

            var rewritten = RelationshipIncluder.Include(ExpressionBuilder, this, translation);

            if (rewritten != translation)
            {
                translation = rewritten;
                translation = UnusedColumnRemover.Remove(translation);
                translation = RedundantColumnRemover.Remove(translation);
                translation = RedundantSubqueryRemover.Remove(translation);
                translation = RedundantJoinRemover.Remove(translation);
            }

            rewritten = SingletonProjectionRewriter.Rewrite(this.ExpressionBuilder, translation);
            if (rewritten != translation)
            {
                translation = rewritten;
                translation = UnusedColumnRemover.Remove(translation);
                translation = RedundantColumnRemover.Remove(translation);
                translation = RedundantSubqueryRemover.Remove(translation);
                translation = RedundantJoinRemover.Remove(translation);
            }

            rewritten = ClientJoinedProjectionRewriter.Rewrite(this, translation);
            if (rewritten != translation)
            {
                translation = rewritten;
                translation = UnusedColumnRemover.Remove(translation);
                translation = RedundantColumnRemover.Remove(translation);
                translation = RedundantSubqueryRemover.Remove(translation);
                translation = RedundantJoinRemover.Remove(translation);
            }

            //
            translation = this.ExpressionBuilder.Translate(translation);

            var        parameters = lambda != null ? lambda.Parameters : null;
            Expression provider   = Find(expression, parameters, typeof(InternalDbContext));

            if (provider == null)
            {
                Expression rootQueryable = Find(expression, parameters, typeof(IQueryable));
                provider = Expression.Property(rootQueryable, typeof(IQueryable).GetProperty("Provider"));
            }

            return(ExecutionBuilder.Build(this.Dialect, this, translation, provider));
        }
示例#7
0
 /// <summary>
 /// Converts a query into an execution plan.  The plan is an function that executes the query and builds the
 /// resulting objects.
 /// </summary>
 /// <param name="projection"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public virtual Expression BuildExecutionPlan(MetaMapping mapping, Expression query, Expression provider)
 {
     return(ExecutionBuilder.Build(mapping, this, query, provider));
 }