Exemple #1
0
 private void AssignValues(string field, ConjunctionsEnum conjunction = ConjunctionsEnum.And,
                           bool quoted = true, Operators op = Operators.EqualTo)
 {
     this.Field       = field;
     this.Conjunction = conjunction;
     this.Quoted      = quoted;
     this.Op          = op;
 }
Exemple #2
0
 public CriteriaBuilder Add(string field, object value, ConjunctionsEnum conjunction, bool quoted, Operators op)
 {
     _criteria.Add
     (
         new Criterion(field, value, conjunction, quoted, op)
     );
     return(this);
 }
Exemple #3
0
 public CriteriaBuilder Add(string field, string[] values, ConjunctionsEnum conjunction = ConjunctionsEnum.And,
                            Operators op = Operators.In)
 {
     return(Add
            (
                new Criterion(field, values, conjunction, op)
            ));
 }
Exemple #4
0
 public CriteriaBuilder AddIfTrue(bool predicate, string field, object value, ConjunctionsEnum conjunction = ConjunctionsEnum.And,
                                  Operators op = Operators.EqualTo)
 {
     if (!predicate)
     {
         return(this);
     }
     return(Add(field, value, conjunction, op));
 }
Exemple #5
0
 public CriteriaBuilder AddDateCriterion(string field, DateTime value,
                                         ConjunctionsEnum conjunction = ConjunctionsEnum.And, Operators op = Operators.EqualTo, bool includeDateComponent = true, bool includeTimeComponent = false)
 {
     return(Add
            (
                GetFormattedDateField(field)
                , GetDateValueFormatedForQuery(value, includeTimeComponent)
                , conjunction
                , op
            ));
 }
Exemple #6
0
        public Criterion(string field, string[] values, ConjunctionsEnum conjunction = ConjunctionsEnum.And, Operators op = Operators.EqualTo)
        {
            var expected = new Operators[]
            {
                Operators.In,
                Operators.NotIn
            };

            if (!expected.Contains(op))
            {
                throw new Exception("Invalid operator '" + op.ToString() + "' passed to criterion");
            }
            AssignValues(field, conjunction, false, op);
            Values = values;
        }
Exemple #7
0
        /// <summary>
        /// Create a new criteria for your query
        /// </summary>
        /// <param name="field">Name of field to query</param>
        /// <param name="value">Value for the field</param>
        /// <param name="conjunction">The relation of this part of the criteria to the preceding parts of the criteria. Placed in front of this field in the query</param>
        /// <param name="quoted">This specifies if the passed value will be enclosed in quotes when query is built</param>
        /// <param name="op">The operator to be applied to this field in the query</param>
        public Criterion(string field, object value, ConjunctionsEnum conjunction = ConjunctionsEnum.And, bool quoted = true, Operators op = Operators.EqualTo)
        {
            var notExpected = new Operators[]
            {
                Operators.In
                , Operators.NotIn
            };

            if (notExpected.Contains(op))
            {
                throw new Exception("Invalid operator '" + op.ToString() + "' passed to criterion");
            }

            AssignValues(field, conjunction, quoted, op);
            Value = value.ToString();
        }
Exemple #8
0
 public CriteriaBuilder Add(string field, object value, ConjunctionsEnum conjunction = ConjunctionsEnum.And, Operators op = Operators.EqualTo)
 {
     return(Add(field, value, conjunction, true, op));
 }