coming soon...
Filter.Serialize<Customer>(t => t.Customers.Select(x => x.Id).Any())
//result: Customers/Select(x: x/Id)/Any()
Filter.Deserialize<Customer>("Numbers/Max(x: x) eq 15")
//result: t => t.Numbers.Max(x => x) == 15
//Support Enumerable,Queryable Methods:
Filter.Deserialize<Customer>("IntArray/Average(x: x) eq 15")
//result: t => t.IntArray.Average(x => x) == 15
Filter.Deserialize<Customer>("Customers/GroupBy(x: x/Id)/Count() eq 15")
//result: t => t.Customers.GroupBy(x => x.Id).Count() == 15
Filter.Deserialize<Customer>("IntArray/Contains(Id)")
//result: t => t.IntArray.Contains(t.Id)
Filter.Deserialize<Customer>("Customers/Select(x: x/Id)/Distinct()/Count() eq 15")
//result: t => t.Customers.Select(x => x.Id).Distinct().Count() == 15
##User functions
//Entity Framework StringConvert methods
var methods = typeof(SqlFunctions)
.GetMethods()
.Where(x => x.Name == "StringConvert").ToArray();
//Register user functions
MethodProvider.RegisterFunction("StringConvert", methods);
Filter.Deserialize<Customer>("StringConvert(Price) eq '1'")
//result: t => SqlFunctions.StringConvert(t.Price) == "1"
Filter.Serialize<Customer>(t => SqlFunctions.StringConvert(t.Price) == "1")
//result: StringConvert(Price) eq '1'
//Support Attributes:
[XmlElement(ElementName = "...")]
[XmlAttributeAttribute(AttributeName = "...")]
[DataMember(Name = "...")]
Filter.Serialize<Customer>(t => t.CustomName1 == 1 || t.CustomName2 == 2 || t.CustomName3 == 3)
//result: cn1 eq 1 or cn2 eq 2 or cn3 eq 3
Filter.Deserialize<Customer>("cn1 eq 1 or cn2 eq 2 or cn3 eq 3")
//result: t => t.CustomName1 == 1 || t.CustomName2 == 2 || t.CustomName3 == 3
##MvcAttribute in Sprint.Filter.OData.Mvc
public ActionResult List([ODataFilterBinder]Expression<Func<Customer,bool>> predicate)
{
....
}
Bugs should be reported through github at https://github.com/artem-sedykh/Sprint.Filter.OData/issues/.