コード例 #1
0
        protected virtual System.Linq.Expressions.Expression <Func <TBaseQuery, bool> > ParseParagraph(QueryComposerCriteriaDTO paragraph)
        {
            //The next operator is used to define the relationship between the current concept with the next concept, if any.
            DTO.Enums.QueryComposerOperators nextOperator = DTO.Enums.QueryComposerOperators.And;

            //Create the paragraph predicate.
            //The predicate is set to TRUE and ANDed with the first concept.
            var paragraphPredicate = PredicateBuilder.True <TBaseQuery>();

            //Process the concepts within the paragraph.
            foreach (var term in paragraph.Terms)
            {
                var termID        = term.Type;
                var termPredicate = PredicateBuilder.True <TBaseQuery>();

                //By default do not apply the term unless it has been registered.
                System.Linq.Expressions.Expression <Func <TBaseQuery, bool> > innerPredicate = null;
                //Parse the term here.
                Func <QueryComposerCriteriaDTO, QueryComposerTermDTO, System.Linq.Expressions.Expression <Func <TBaseQuery, bool> > > action = null;
                if (TermPredicateBuilders.TryGetValue(term.Type, out action))
                {
                    //The term has been registered replace the inner predicate.
                    innerPredicate = action(paragraph, term);
                }

                if (innerPredicate == null)
                {
                    continue;
                }

                termPredicate = termPredicate.And(innerPredicate.Expand());

                if (nextOperator == DTO.Enums.QueryComposerOperators.And)
                {
                    paragraphPredicate = paragraphPredicate.And(termPredicate.Expand());
                }
                else
                {
                    paragraphPredicate = paragraphPredicate.Or(termPredicate.Expand());
                }
                //Handle AndNot and OrNot here.
                nextOperator = term.Operator;
            }

            foreach (var paragraphAction in ParagraphPredicateBuilders)
            {
                //the predicate method is responsible for determining how to apply to the paragraph predicate
                paragraphPredicate = paragraphAction(paragraph, paragraphPredicate);
            }



            //TODO: parse the child criteria and append to the paragraph predicate

            return(paragraphPredicate);
        }
コード例 #2
0
 /// <summary>
 /// Implementation to merge two predicates together.
 /// </summary>
 /// <param name="queryPredicate"></param>
 /// <param name="nextParagraphPredicate"></param>
 /// <param name="conjunction"></param>
 /// <returns></returns>
 protected virtual System.Linq.Expressions.Expression <Func <TBaseQuery, bool> > MergeParagraphPredicates(System.Linq.Expressions.Expression <Func <TBaseQuery, bool> > queryPredicate,
                                                                                                          System.Linq.Expressions.Expression <Func <TBaseQuery, bool> > nextParagraphPredicate, DTO.Enums.QueryComposerOperators conjunction, bool isExclusion)
 {
     throw new NotImplementedException();
 }