I have a way like this:
public ICollection<T> GetEntitiesWithPredicate(Expression<Func<T, bool>> predicate) {
I am calling a method call in another class, for example
service.GetEntitiesWithPredicate(x => x.FoobarCollection.Where(y => y.Text.Contains(SearchText)));
but I always get this error:
Lambda expression cannot be converted to '<typename>' because '<typename>' is not a delegate type
What do I need to change to get this job?
Edit:
I use Entity Framework 6, and if I use Any () instead of Where (), I always get only one result back ... I want to pass the expression to my EF implementation:
public ICollection<T> GetEntriesWithPredicate(Expression<Func<T, bool>> predicate) { using (var ctx = new DataContext()) { return query.Where(predicate).ToList(); } }
source share