Beispiel #1
0
        static DbExpression ParseFilter(QueryModel queryModel, LambdaExpression filter)
        {
            ScopeParameterDictionary scopeParameters = queryModel.ScopeParameters.Clone(filter.Parameters[0], queryModel.ResultModel);
            DbExpression             filterCondition = FilterPredicateParser.Parse(filter, scopeParameters, queryModel.ScopeTables);

            return(filterCondition);
        }
Beispiel #2
0
        public virtual IQueryState Accept(WhereExpression exp)
        {
            ScopeParameterDictionary scopeParameters = this._queryModel.ScopeParameters.Clone(exp.Predicate.Parameters[0], this._queryModel.ResultModel);

            DbExpression whereCondition = FilterPredicateParser.Parse(exp.Predicate, scopeParameters, this._queryModel.ScopeTables);

            this._queryModel.AppendCondition(whereCondition);

            return(this);
        }
 DbExpression ParseCondition(LambdaExpression condition, ComplexObjectModel objectModel, StringSet scopeTables)
 {
     if (condition == null)
     {
         return(null);
     }
     return(FilterPredicateParser.Parse(condition, new ScopeParameterDictionary(1)
     {
         { condition.Parameters[0], objectModel }
     }, scopeTables));
 }
Beispiel #4
0
        public virtual IQueryState Accept(GroupingQueryExpression exp)
        {
            foreach (LambdaExpression item in exp.GroupKeySelectors)
            {
                var keySelector = (LambdaExpression)item;
                ScopeParameterDictionary scopeParameters = this._queryModel.ScopeParameters.Clone(keySelector.Parameters[0], this._queryModel.ResultModel);

                this._queryModel.GroupSegments.AddRange(GroupKeySelectorParser.Parse(keySelector, scopeParameters, this._queryModel.ScopeTables));
            }

            foreach (LambdaExpression havingPredicate in exp.HavingPredicates)
            {
                ScopeParameterDictionary scopeParameters = this._queryModel.ScopeParameters.Clone(havingPredicate.Parameters[0], this._queryModel.ResultModel);

                var havingCondition = FilterPredicateParser.Parse(havingPredicate, scopeParameters, this._queryModel.ScopeTables);
                this._queryModel.AppendHavingCondition(havingCondition);
            }

            if (exp.Orderings.Count > 0)
            {
                this._queryModel.Orderings.Clear();
                this._queryModel.InheritOrderings = false;

                for (int i = 0; i < exp.Orderings.Count; i++)
                {
                    GroupingQueryOrdering groupOrdering = exp.Orderings[i];

                    ScopeParameterDictionary scopeParameters = this._queryModel.ScopeParameters.Clone(groupOrdering.KeySelector.Parameters[0], this._queryModel.ResultModel);

                    DbExpression orderingDbExp = GeneralExpressionParser.Parse(groupOrdering.KeySelector, scopeParameters, this._queryModel.ScopeTables);

                    DbOrdering ordering = new DbOrdering(orderingDbExp, groupOrdering.OrderType);
                    this._queryModel.Orderings.Add(ordering);
                }
            }

            QueryModel newQueryModel = this.CreateNewQueryModel(exp.Selector);

            return(new GroupingQueryState(newQueryModel));
        }