public override Expression ToExpression(ParameterExpression paramExpr) { var navExpr = NavPropBlock.ToExpression(paramExpr); var elementType = NavPropBlock.Property.ElementType; MethodInfo mi; if (Operator == Operator.Any) { mi = TypeFns.GetMethodByExample((IEnumerable <String> list) => list.Any(x => x != null), elementType); } else { mi = TypeFns.GetMethodByExample((IEnumerable <String> list) => list.All(x => x != null), elementType); } var lambdaExpr = Predicate.ToLambda(elementType); var result = Expression.Call(mi, navExpr, lambdaExpr); return(result); }
public override Expression ToExpression(ParameterExpression paramExpr) { var navExpr = NavPropBlock.ToExpression(paramExpr); var elementType = NavPropBlock.Property.ElementType; MethodInfo mi; if (Operator == Operator.Any) { mi = TypeFns.GetMethodByExample((IQueryable <string> list) => list.Any(x => x != null), elementType); } else { mi = TypeFns.GetMethodByExample((IQueryable <string> list) => list.All(x => x != null), elementType); } var lambdaExpr = Predicate.ToLambda(elementType); var castType = typeof(IQueryable <>).MakeGenericType(new Type[] { elementType }); var castNavExpr = Expression.Convert(navExpr, castType); var result = Expression.Call(mi, castNavExpr, lambdaExpr); return(result); }