示例#1
0
 public static Term IsEqual(this MatchField <string> field, string condition)
 {
     return(new Term(field, condition)
     {
         TermType = IsWild(condition) ? TermType.Wild : TermType.Match
     });
 }
示例#2
0
 public static Term IsNotEqual(this MatchField <int> field, int condition)
 {
     return(new Term(field, condition.ToString())
     {
         TermType = TermType.Match, Inverted = true
     });
 }
示例#3
0
 public static Term Exists(this MatchField <string> field)
 {
     return(new Term(field, String.Empty)
     {
         TermType = TermType.Exists
     });
 }
示例#4
0
 public static Term IsEqualAll(this MatchField <int> field, params int[] conditions)
 {
     //Since its not wild (as an integer type), use a MatchAll command
     return(new Term(field, conditions.Select(i => i.ToString()))
     {
         TermType = TermType.MatchAll
     });
 }
示例#5
0
        public static Term IsNotEqual(this MatchField <string> field, string condition)
        {
            var wild = IsWild(condition);

            return(new Term(field, condition)
            {
                TermType = wild ? TermType.Wild : TermType.Match, Inverted = true
            });
        }
示例#6
0
        public static Term IsEqualAll(this MatchField <string> field, params string[] conditions)
        {
            //validate input
            if ((conditions == null) || (conditions.Count() < 1))
            {
                throw new InvalidOperationException("IsEqualAll requires at least one condition ");
            }

            //If any of the conditions are wild cards we need to behave differently
            var isWild = false;

            foreach (var condition in conditions)
            {
                if (IsWild(condition))
                {
                    isWild = true;
                }
            }

            //If it has a wild card statement, instead join them using individual matches and wilds
            if (isWild)
            {
                var terms = new List <Term>();
                var first = true;
                foreach (var condition in conditions)
                {
                    var term = new Term(field, condition)
                    {
                        TermType = IsWild(condition) ? TermType.Wild : TermType.Match
                    };
                    if (!first)
                    {
                        term.Operator = OperatorType.And;
                    }
                    else
                    {
                        first = false;
                    }
                    terms.Add(term);
                }
                return(new Term(terms.ToArray()));
            }

            //Since its not wild, use a MatchAll command
            return(new Term(field, conditions)
            {
                TermType = TermType.MatchAll
            });
        }
示例#7
0
        public static Term IsEqualOnly(this MatchField <string> field, EqualOnlyBehaviour behaviour, params string[] conditions)
        {
            if (behaviour == EqualOnlyBehaviour.SkipFieldCheck)
            {
                return(new Term(field, conditions)
                {
                    TermType = TermType.MatchCover
                });
            }

            return((new Term(field, conditions)
            {
                TermType = TermType.MatchCover
            }) & field.Exists());
        }