Sometimes it's nice to be able to store lambda expressions somewhere that mean something in your business logic, for example
Expression<Func<Supplier,bool>> SupplierHasHighRating = x => x.Rating > 90;
This is like a lite form of the Specification Pattern. So you can do this:
var highRatedSuppliers = someQueryableOfSuppliers.Where(SupplierHasHighRating);
What I'd like to know if there is a way I can reuse the lambda in a query against a different object which is related to Supplier:
var productsOfHighRatedSuppliers = someQueryableOfProducts.Where(x => x.Supplier.Rating > 90);
Can I reuse the lambda here somehow?
Edit: If you believe the answer is yes, can you show how you would do it in terms of the above example?