I have recreated the Predicatebuilder class in a seperate C# project and I'm trying to use it in a VB.NET project but I keep getting the following error:
Overload resolution failed because no accessible 'Or' accepts this number of arguments.
when I use it like so:
Dim predicate = PredicateBuilder.False(Of t_Quote)()
predicate = predicate.Or(Function(q) q.iQuoteType = iQuoteType)
The relivant project is referenced, I'm using the correct imports statement and it all compiles without any errors.
Any idea where I'm going wrong?
Here is the PredicateBuilder class in C# I'm using:
public static class PredicateBuilder { public static Expression> True() { return f => true; } public static Expression> False() { return f => false; }
public static Expression<Func<T, bool>> Or<T>(this
Expression> expr1, Expression> expr2) { var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast()); return Expression.Lambda> (Expression.OrElse(expr1.Body, invokedExpr), expr1.Parameters); }
public static Expression<Func<T, bool>> And<T>(this
Expression> expr1, Expression> expr2) { var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast()); return Expression.Lambda> (Expression.AndAlso(expr1.Body, invokedExpr), expr1.Parameters); } }