Exemplo n.º 1
0
        private void AddComparisonValue(StringBuilder queryBuilder, Criteria criteria, SearchOptions options)
        {
            switch(criteria.Condition)
            {
                case SearchCondition.Contains:
                    if (options.IsMappingSearch && options.CaseSensitivity == false)
                    {
                        queryBuilder.Append(".ToUpper().Contains");
                        queryBuilder.Append("(");
                        queryBuilder.Append(FormattedValue(criteria).ToUpper());
                        queryBuilder.Append(")");
                    }
                    else
                    {
                        queryBuilder.Append(".Contains");
                        queryBuilder.Append("(");
                        queryBuilder.Append(FormattedValue(criteria));
                        queryBuilder.Append(")");
                    }
                    break;

                default:
                    queryBuilder.Append(Operator(criteria.Condition));
                    queryBuilder.Append(FormattedValue(criteria));
                    break;
            }
        }
Exemplo n.º 2
0
        private static string FormattedValue(Criteria criteria)
        {
            const string Quote = "\"";

            if (criteria.Condition == SearchCondition.NumericEquals || (criteria.IsNumeric.HasValue && criteria.IsNumeric == true))
            {
                return criteria.ComparisonValue;
            }

            return Quote + criteria.ComparisonValue + Quote;
        }
Exemplo n.º 3
0
        public void ToStringForStringValue()
        {
            var x = new Criteria { Field = "x", Condition = SearchCondition.Equals, ComparisonValue = "fred" };

            Assert.AreEqual("x = \"fred\"", x.ToString());
        }
Exemplo n.º 4
0
        public void NonDefaultHashCode()
        {
            var x = new Criteria { Field = "x", Condition = SearchCondition.Equals, ComparisonValue = "5", IsNumeric = true };

            var y = x.GetHashCode();
        }
Exemplo n.º 5
0
        public void DefaultHashCode()
        {
            var x = new Criteria();

            var y = x.GetHashCode();
        }
Exemplo n.º 6
0
        public void ToStringForNumericValue()
        {
            var x = new Criteria { Field = "x", Condition = SearchCondition.Equals, ComparisonValue = "5", IsNumeric = true };

            Assert.AreEqual("x = 5", x.ToString());
        }