I'm trying to implement a generic method with predicate. I wrote some code:
public ICollection<T> GetProductsByMatching<T>(Expression<Func<T, bool>> predicate)
{
return context.Products.Where(predicate).Include("ShopPlace, Images").ProjectTo<T>().ToList();
}
And usage of this method:
var a = service.GetProductsByMatching<ProductInfo>(x => x.Name.StartsWith("value")
|| x.Price < 150);
Finally I have Invalid Operation Exception
: No generic method 'Where' on type 'System.Linq.Queryable' is compatible with the supplied type arguments and arguments.
Whats wrong with my code? Thanks for advance!