public Expression Build(IFilterChoice filter, Expression itemExpression) { Expression?filterExpr = null; switch (filter) { case AndFilter af: filterExpr = BuildAndFilter(af, itemExpression); break; case OrFilter of: filterExpr = BuildOrFilter(of, itemExpression); break; case PresentFilter pf: filterExpr = BuildPresentFilter(pf, itemExpression); break; case EqualityMatchFilter eq: filterExpr = BuildEqualityFilter(eq, itemExpression); break; case SubstringFilter sf: filterExpr = BuildSubstringFilter(sf, itemExpression); break; default: throw new NotImplementedException("Filter for " + filter.GetType() + " is not implemented"); } return(BuildWithBaseFilter(filterExpr, itemExpression)); }
public void TestBuild(IFilterChoice filter, string expected) { ParameterExpression paramExpression = Expression.Parameter(typeof(AppUser)); SearchExpressionBuilder builder = new SearchExpressionBuilder(); Expression result = builder.Build(filter, paramExpression); Assert.Equal(expected, result.ToString()); }