We have a simple database and we are trying to retrieve db records asynchronously with EntityFramework in an MVC5 application like so:
var result = await dbcontext.Emails.Where(e=>e.name.StartsWith("ask")).ToListAsync;
return View(result);
OR
var result = dbcontext.Emails.Where(e=>e.name.StartsWith("ask"));
return View(await result.ToListAsync());
However we do not even get the option of using the ToListAsync (only ToList) even though the Where clause produces an IQueryable. We are using EF6 of course. Any help would be greatly appreciated.
The ToListAsync
is an extension method defined in the class System.Data.Entity.QueryableExtensions
You are probably not importing the namespace...
eg using System.Data.Entity;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.