在NTT Framework和MVC 5 Web应用程序中,我有时想从非异步方法中调用一个等待的方法,如下所示:
private List<DormObject> GetAllActiveDorms()
{
using (ApplicationDbContext Db = new ApplicationDbContext())
{
return Db.Dorms
.Select( d => new DormObject
{
ID = d.ID,
Name = d.Name,
Address = d.Address,
AdminName = (await UserManager.FindByIdAsync(d.AdminID)).UserName,
Gender = d.Gender
}).ToList() ?? new List<DormObject> { };
}
}
这种方式是不可能的!这个异步方法也在lambda表达式中调用!
我如何收到&#39;用户名&#39;值?