I have some code
var battleDetails = await _dbContext.BattleDetails
.Select(x => new
{
x.Hero,
BattlesCount = _dbContext.BattleDetails
.Count(y => y.Hero == x.Hero)
})
.ToListAsync();
And I want to use CountAsync
method instead of Count
, but when I try to do this I am getting an error.
I have tried multiple ways, FE
.Select(async x => new
{
x.Hero,
BattlesCount = await _dbContext.BattleDetails
.CountAsync(y => y.Hero == x.Hero)
})
What should I do to make it async?