Probably you are inside a Background Task.
Remember that if all Foreground Task end, all background task will be killed.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
If I use var result=query.ToList();
it is ok
If I use var result =await query.ToListAsync();
there will be error :
An error occurred using the connection to database on server System.Threading.Tasks.TaskCanceledException
Probably you are inside a Background Task.
Remember that if all Foreground Task end, all background task will be killed.
@Zhi Lv - MSFT I find the problem it was a requestFilter I add in Program.cs
public Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
next();
return Task.CompletedTask;
}
I remove the filter it is ok but I add the filter is is not ok.
Hi,
You can do that, however your method should be async Task as shown:
public async Task<List<customer>> GetDotNetCount()
{
var customers = await cuatomerQuery.ToListAsync();
return customers;
}