コード例 #1
0
        public SelectStatement ApplyCondition(SelectStatement statement)
        {
            var extractor = new CriteriaOperatorExtractor();
            extractor.Extract(statement.Condition);
            traceStatement(statement, "ApplyCondition");

            foreach (FilterProviderBase provider in FilterProviderManager.Providers)
            {
                FilterProviderBase providerBase = FilterProviderManager.GetFilterProvider(provider.FilterMemberName);
                if (providerBase!= null)
                {
                    Tracing.Tracer.LogVerboseValue("providerName", providerBase.Name);
                    IEnumerable<BinaryOperator> binaryOperators =
                        extractor.BinaryOperators.Where(
                            @operator =>
                            @operator.RightOperand is OperandValue &&
                            ReferenceEquals(((OperandValue) @operator.RightOperand).Value, providerBase.FilterMemberName));
                    if (!FilterIsShared(statement.TableName,providerBase.Name) && binaryOperators.Count() == 0&&!IsSystemTable(statement.TableName))
                    {
                        string s = providerBase.FilterValue== null? null:providerBase.FilterValue.ToString();

                        string nodeAlias = statement.Operands.OfType<QueryOperand>().Where(
                                               operand => operand.ColumnName == providerBase.FilterMemberName).Select(
                                               operand => operand.NodeAlias).FirstOrDefault() ?? statement.Alias;
                        statement.Condition &= new QueryOperand(providerBase.FilterMemberName, nodeAlias) ==s;
                        Tracing.Tracer.LogVerboseValue("new_statement", statement);
                    }
                }
            }
            return statement;
        }
コード例 #2
0
 public void ExtractGroupOperator()
 {
     BinaryOperator binaryOperator2;
     CriteriaOperator groupOperator;
     BinaryOperator binaryOperator = getGroupOperator(out binaryOperator2, out groupOperator);
     var extractor = new CriteriaOperatorExtractor();
     extractor.Extract(groupOperator);
     Assert.AreEqual(binaryOperator, extractor.BinaryOperators[0]);
     Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[1]);
 }
コード例 #3
0
        public void ExtractNestedGroupOperator()
        {
            BinaryOperator binaryOperator2;
            CriteriaOperator nestedGroupOperator;
            BinaryOperator binaryOperator1 = getGroupOperator(out binaryOperator2, out nestedGroupOperator);
            var groupOperator = new GroupOperator(nestedGroupOperator, binaryOperator1, binaryOperator2);
            CriteriaOperator containsOperator = new ContainsOperator("", groupOperator);

            var extractor = new CriteriaOperatorExtractor();
            extractor.Extract(containsOperator);

            Assert.AreEqual(4, extractor.BinaryOperators.Count);
            Assert.AreEqual(binaryOperator1, extractor.BinaryOperators[0]);
            Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[1]);
            Assert.AreEqual(binaryOperator1, extractor.BinaryOperators[2]);
            Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[3]);
        }
コード例 #4
0
 private CriteriaOperatorExtractor GetBinaryOperatorExtractor(CriteriaOperator criteriaOperator)
 {
     var binaryOperatorExtractor = new CriteriaOperatorExtractor();
     binaryOperatorExtractor.Extract(criteriaOperator);
     return binaryOperatorExtractor;
 }