/// <summary> /// Creates the filter expression from this instance of filter rule. /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public Expression <Func <T, bool> > GetExpression <T>() { var typeToCompare = Value != null?Value.GetType() : typeof(object); var provider = FilterExpressionProviderFactory.GetProvider(typeToCompare, Operator); return(provider.CreateFilterExpression <T>(Expression, Operator, Value)); }
/// <summary> /// Initializes a new instance of the <see cref="ComplexFilterRule{TEntity}"/> class. /// </summary> /// <param name="rules">The rules to join using OR operator.</param> internal ComplexFilterRule(IEnumerable <FilterRule> rules) { argument = Expression.Parameter(typeof(TEntity), "x"); foreach (var filterRule in rules) { var typeToCompare = filterRule.Value != null?filterRule.Value.GetType() : typeof(object); var provider = FilterExpressionProviderFactory.GetProvider(typeToCompare, filterRule.Operator); var condition = provider.CreateConditionExpression(argument, filterRule.Expression, filterRule.Operator, filterRule.Value); filterBody = filterBody != null ? Expression.OrElse(condition, filterBody) : condition; } }