How to adhere to abstraction and asynchrony

1 day ago 4
ARTICLE AD BOX
public async Task<IEnumerable<Patient>> GetWaitingPatientsAsync() { return await _context.Patients.AsNoTracking().Where(x => x.Status == PatientStatus.Waiting).ToListAsync(); }

I have a method like this in my repository . It returns an abstraction, but I have to override this abstraction with ToListAsync and pass a list to the service layer instead of an IEnumerable. I can't avoid using ToListAsync here because await waits for a Task<T> and Where() returns an IQueryable. I'm now faced with a dilemma: I want to preserve the asynchronicity but also not break the abstraction. What do you recommend? Should I break the abstraction?

Read Entire Article