6
我嘗試調用EF方法ToListAsync。但沒有發生 - 沒有例外,沒有超時正在運行。EntityFramework ToListAsync()不起作用
這是我的代碼。
private IQueryable<Place> placeCompleteQuery;
protected IQueryable<Place> PlaceCompleteQuery
{
get
{
return this.placeCompleteQuery ?? (this.placeCompleteQuery = this.Context.Places.Include(p => p.Address).
Include(p => p.CreatedBy).
Include(p => p.Source).
Include(p => p.Type.Translations).
Include(p => p.Ratings));
}
}
public async Task<IList<Place>> GetPlacesByLocationAsync(DbGeography location, int radius)
{
List<Place> temporaryResult = PlaceCompleteQuery.Where(p => p.Location.Distance(location) <= radius).
ToList();
return await PlaceCompleteQuery.Where(p => p.Location.Distance(location) <= radius).
ToListAsync();
}
ToList方法的第一次同步調用立即返回結果。 ToListAsync的第二個異步調用仍然運行,沒有結果也沒有異常。
有什麼建議嗎?
你說得對。我沒有像async一樣標記Controller方法。謝謝你的幫助。 –