I want to create a method to be reused in where clauses in other conditions.
I have something like this:
public static bool IsActive(this Store store, DateTime date)
{
return store.StartDate <= date && (store.EndDate == null || storeSku.EndDate > date);
}
and I would like to use it like:
var activeStores = _dbContext.Store.Where(s => s.IsActive(date) && !s.deleted);
var toDeletedStores = _dbContext.Store.Where(s => !s.IsActive(date) && !s.deleted);
My problem when I do this is that the code is not translatable to sql. Can you tell me how to create this as reusable code that is translatable to SQL ?