public void Succeeds() { var search = new DecimalSearch(nameof(Item.Value)); var result = search.ApplyToQuery(Items().AsQueryable()).ToArray(); result.Length.Should().Be(3); }
public void Child_Succeeds() { Expression <Func <Foo, object> > expression = foo => foo.Bar.Value; var property = expression.ToString(); var search = new DecimalSearch(property); var result = search.ApplyToQuery(Foos().AsQueryable()).ToArray(); result.Length.Should().Be(2); result[0].Id.Should().Be(4); result[1].Id.Should().Be(5); }
public void Less_Succeeds() { var search = new DecimalSearch(nameof(Item.Value)) { Term1 = 2.1M, Is = DecimalSearch.Comparer.Less }; var result = search.ApplyToQuery(Items().AsQueryable()).ToArray(); result.Length.Should().Be(1); result[0].Id.Should().Be(1); }
public void Children_Equals_Succeeds() { var search = new DecimalSearch($"Bars.{nameof(Bar.Value)}") { Is = DecimalSearch.Comparer.Equal, Term1 = 5.0M }; var result = search.ApplyToQuery(Foos2().AsQueryable()).ToArray(); result.Length.Should().Be(1); result[0].Id.Should().Be(6); }
public void Child_Equals_Succeeds() { Expression <Func <Foo, object> > expression = foo => foo.Bar.Value; var propert = expression.GetPropertyPath(); var property = string.Join(".", PropertyPath <Foo> .Get(x => x.Bar.Value).Select(x => x.Name)); var search = new DecimalSearch(property) { Is = DecimalSearch.Comparer.Equal, Term1 = 2.1M }; var result = search.ApplyToQuery(Foos().AsQueryable()).ToArray(); result.Length.Should().Be(1); result[0].Id.Should().Be(5); }
private static AbstractSearch CreateSearchCriterion(Type targetType, Type propertyType, string property) { AbstractSearch result = null; if (propertyType.IsCollectionType()) { propertyType = propertyType.GetGenericArguments().First(); } if (propertyType.IsEnum) { result = new EnumSearch(propertyType); } else if (propertyType == typeof(string)) { result = new TextSearch(); } else if (propertyType == typeof(bool) || propertyType == typeof(bool?)) { result = new BooleanSearch(); } else if (propertyType == typeof(byte) || propertyType == typeof(byte?)) { result = new ByteSearch(); } else if (propertyType == typeof(char) || propertyType == typeof(char?)) { result = new CharacterSearch(); } else if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?)) { result = new DateSearch(); } else if (propertyType == typeof(decimal) || propertyType == typeof(decimal?)) { result = new DecimalSearch(); } else if (propertyType == typeof(double) || propertyType == typeof(double?)) { result = new DoubleSearch(); } else if (propertyType == typeof(float) || propertyType == typeof(float?)) { result = new FloatSearch(); } else if (propertyType == typeof(int) || propertyType == typeof(int?)) { result = new IntegerSearch(); } else if (propertyType == typeof(long) || propertyType == typeof(long?)) { result = new LongSearch(); } else if (propertyType == typeof(sbyte) || propertyType == typeof(sbyte?)) { result = new SByteSearch(); } else if (propertyType == typeof(short) || propertyType == typeof(short?)) { result = new ShortSearch(); } else if (propertyType == typeof(uint) || propertyType == typeof(uint?)) { result = new UnsignedIntegerSearch(); } else if (propertyType == typeof(ulong) || propertyType == typeof(ulong?)) { result = new UnsignedLongSearch(); } else if (propertyType == typeof(ushort) || propertyType == typeof(ushort?)) { result = new UnsignedShortSearch(); } if (result != null) { result.Property = property; result.TargetTypeName = targetType.AssemblyQualifiedName; } return(result); }
public static Expression BuildDoubleSearch <TEntity>(Expression target, ParameterExpression parameter, Expression <Func <TEntity, decimal> > getter, DecimalSearch search) { return(BuildMultiValueSearch(target, parameter, getter, search)); }