Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Core how to make Any Async?

    public async Task<bool> IsParagemOnGoingAsync(int registoId)
    {
       return await _context.ParagensRegistos
           .Where(pr => pr.RegistoId == registoId)
           .Any(pr => pr.HoraFim == null);
    }

how can i make this async? I can't find anythig on google...

EDIT

I knew about AnyAsync();

I tried like multiple times and never had intellisense to add the reference.

like image 520
Jackal Avatar asked Oct 16 '25 05:10

Jackal


1 Answers

You can use AnyAsync()

 public async Task<bool> IsParagemOnGoingAsync(int registoId)
    {
       return await _context.ParagensRegistos
           .Where(pr => pr.RegistoId == registoId)
           .AnyAsync(pr => pr.HoraFim == null);
    }

More info on AnyAsync() here

like image 82
Ismael Padilla Avatar answered Oct 17 '25 17:10

Ismael Padilla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!