public void CustomInOperator_Test() { var rec = new MyRecord(); rec.UserHostAddress = "8.10.8.13"; var records = new List <MyRecord>() { rec }; var myFilter = new QueryBuilderFilterRule() { Condition = "and", Rules = new List <QueryBuilderFilterRule>() { new QueryBuilderFilterRule() { Condition = "and", Field = "UserHostAddress", Operator = "in_ip_range", Type = "string", Value = new [] { "10.10.10.*" } } } }; var options = new BuildExpressionOptions(); options.Operators = new List <IFilterOperator>() { new InIpRangeOperator() }; var result = records.AsQueryable().BuildQuery <MyRecord>(myFilter, options).ToList(); var len = result.Count; Assert.AreEqual(1, len); }
public Expression GetExpression(Type type, IFilterRule rule, Expression propertyExp, BuildExpressionOptions options) { return(Expression.Call(this.GetType().GetMethod("ContainsIP"), new[] { propertyExp, Expression.Constant(rule.Value) })); }