Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning Task<bool> from LINQ's Any method?

I have this interface :

public interface ISign
{
   Task<bool> IsRegisteredCopy();
}

Implemented it:

public class Sign : ISign
    {
        TabibContext context = new TabibContext();
        public Task<bool> IsRegisteredCopy()
        {
            return context.Doctors.Any();
        }
    }

So I need to return Task from Any method which is not available!

like image 857
mshwf Avatar asked Jan 04 '23 10:01

mshwf


1 Answers

Entity Framework has various async extensions you can use in the System.Data.Entity namespace. So you can do this:

using System.Data.Entity;

public Task<bool> IsRegisteredCopy()
{
    return context.Doctors.AnyAsync();
}
like image 83
DavidG Avatar answered Jan 14 '23 05:01

DavidG