I have this entity, lets call it Car, which I have created a filter for.
public static Expression<Func<Car, bool>> FilterCars(int something) { ...}
It works when I query the database like this:
Repository.GetAll<Car>().Where(FilterCars(1));
The problem is that i also have this one-to-one relation where i would like to reuse this filter.
Lets say that a person only have one car, and I only want people who owns car that matches my filter, almost like this:
Repository.GetAll<Person>().Where(p => p.Car.Matches(FilterCars(1));
I have invented the matches method. But it is something like that I am looking for.
Does anyone know a way to "filter a single object" in a database query?