Exemplo n.º 1
0
        public void ConstructRangeFilterTerm()
        {
            var name = Guid.NewGuid().ToString();
            var from = 99;
            var to   = 6563;
            var term = new RangeFilterTerm(name, from, to);

            Assert.Equal(name, term.PropertyName);
            Assert.Equal(FilterOperators.Range, term.Operator);
            Assert.Equal(from, term.From);
            Assert.Equal(to, term.To);
        }
Exemplo n.º 2
0
        private Tuple <string, IList <TDbParameter> > GenerateBetweenCondition(RangeFilterTerm term)
        {
            var fieldName  = GetColumnName(term.PropertyName);
            var p1Name     = GetParameterName();
            var p2Name     = GetParameterName();
            var clause     = $"{fieldName} BETWEEN {p1Name} AND {p2Name}";
            var parameters = new List <TDbParameter>
            {
                GetDbParameter(p1Name, term.From),
                GetDbParameter(p2Name, term.To)
            };

            return(new Tuple <string, IList <TDbParameter> >(clause, parameters));
        }
Exemplo n.º 3
0
        private RangeFilterTerm ConvertToTypedTerm(RangeFilterTerm term)
        {
            var field = term.PropertyName.ToLower();

            if (!_typeMembers.ContainsKey(field))
            {
                throw new InvalidOperationException($"No public member on {Type} called {field} - case insensitive search");
            }

            var member    = _typeMembers[field];
            var fromValue = StringConverter.FromString((string)term.From, member.Type);
            var toValue   = StringConverter.FromString((string)term.To, member.Type);

            return(new RangeFilterTerm(member.Name, fromValue, toValue));
        }