public void TestToComparisonType()
 {
     Assert.AreEqual(ComparisonType.Equal, ComparisonType.ToComparisonType(ComparisonType.Equal.Value));
     Assert.AreEqual(ComparisonType.GreaterThan, ComparisonType.ToComparisonType(ComparisonType.GreaterThan.Value));
     Assert.AreEqual(ComparisonType.In, ComparisonType.ToComparisonType(ComparisonType.In.Value));
     Assert.AreEqual(ComparisonType.LessThan, ComparisonType.ToComparisonType(ComparisonType.LessThan.Value));
     Assert.AreEqual(ComparisonType.Like, ComparisonType.ToComparisonType(ComparisonType.Like.Value));
     Assert.AreEqual(ComparisonType.NotNull, ComparisonType.ToComparisonType(ComparisonType.NotNull.Value));
     Assert.AreEqual(ComparisonType.Null, ComparisonType.ToComparisonType(ComparisonType.Null.Value));
     Assert.AreEqual(ComparisonType.NotIn, ComparisonType.ToComparisonType(ComparisonType.NotIn.Value));
     Assert.AreEqual(ComparisonType.ContainsAny, ComparisonType.ToComparisonType(ComparisonType.ContainsAny.Value));
 }
Esempio n. 2
0
        /// <summary>
        /// Returns a LinqFilter to be used in linq queries.
        /// </summary>
        /// <typeparam name="T">The object type to filter.</typeparam>
        /// <returns>The linq filter.</returns>
        public LinqFilter <T> ToLinqFilter <T>() where T : class
        {
            var comparisonType = ComparisonType.ToComparisonType(this.Comparison);

            Contract.Assume(comparisonType != null, "The comparison type must not be null.");
            if (comparisonType == ComparisonType.Equal)
            {
                return(new EqualFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.NotEqual)
            {
                return(new NotEqualFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.GreaterThan)
            {
                return(new GreaterThanFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.LessThan)
            {
                return(new LessThanFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.NotNull)
            {
                return(new NullFilter <T>(this.Property, true));
            }
            if (comparisonType == ComparisonType.Null)
            {
                return(new NullFilter <T>(this.Property, false));
            }
            if (comparisonType == ComparisonType.Like)
            {
                return(new LikeFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.In)
            {
                return(new InFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.NotIn)
            {
                return(new NotInFilter <T>(this.Property, this.Value));
            }
            if (comparisonType == ComparisonType.ContainsAny)
            {
                return(new ContainsAnyFilter <T>(this.Property, this.Value));
            }
            throw new NotSupportedException("The client filter is not supported.");
        }
        public void TestToComparisonType_CaseInsensitive()
        {
            var key = "eQ";

            Assert.AreEqual(ComparisonType.Equal, ComparisonType.ToComparisonType(key));
        }
Esempio n. 4
0
 /// <summary>
 /// Returns a string of this simple filter.
 /// </summary>
 /// <returns>A string of this simple filter.</returns>
 public override string ToString()
 {
     return(String.Format("{0} {1} {2}", this.Property, ComparisonType.ToComparisonType(this.Comparison), this.Value == null ? "null" : this.Value.ToString()));
 }