Is there a way to filter based on a property in EF
public async Task<Challenge?> GetByIdAsync(int id)
{
var item = await _context.Challenges
.Include(x => x.Upload) // Where Upload.DeletedOn == null Else null
.FirstOrDefaultAsync(x => x.Id == id && x.DeletedOn == null);
return item;
}
I know I can filter afterwards but I don’t want to do that and increase complexity as there’ll be 100+ APIs that require a somewhat similar filter.
Tried to go through this but this is not on a one-to-one relationship – filtered-include