This is the query:
using (var db = new AppDbContext())
{
var items = await db.Branches
.Where(b => b.OrgId == orgId)
.Select(t => new SelectListItem<int> {Key = t.Id, Value = t.Name})
.ToListAsync();
return items;
}
If I replace ToListAsync
with ToList
, it runs fine, but otherwise it hangs. I suspect some sort of threading issue. The query is called during my viewmodel's InitializeAsync
method, which is called from an 'event' in the view:
public override async void OnNavigatedTo(NavigationContext navigationContext)
{
await InitializeModelAsync(InitModelCts.Token);
}
This is part of the view's implementation of INavigationAware
.