why i cannot await 'System.Linq.IQueryable

asynchronous c# entity-framework entity-framework-6 linq

Question

I have the following repository method:-

  public  IQueryable<TSet> getAllScanEmailTo()
        {
         return   t.TSets.Where(a=>a.Name.StartsWith("ScanEmail"));

        }

which is being called as follow:-

var emailsTo = repository.getAllScanEmailTo().ToList();

now i tried to change the above to be using async so i modifed my repository method to be as follow:-

 public async Task<  IQueryable<TSet>> getAllScanEmailTo()
        {
         return  await t.TSets.Where(a=>a.Name.StartsWith("ScanEmail"));

        }

but i got the following error :-

Error   1   Cannot await 'System.Linq.IQueryable<Final.Models.TSet>'
1
-4
9/22/2015 3:55:16 PM

Accepted Answer

Since you mentioned you are using EF6, you can use .ToListAsync(). Then you can await on that.

7
9/22/2015 3:59:47 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow