Hi @osyris ,
return await data.ToListAsync();
The issue might be related the above code, I create a sample to test your code, when using the ToListAsync()
method, it will show the following exception:
The source 'IQueryable' doesn't implement ''. Only sources that implement 'IAsyncEnumerable' can be used for Entity Framework asynchronous operations.
Then, if I change the ToListAsync()
method to ToList()
method, everything works well on my side.
You can refer the following code and try to use return await Task.FromResult(data.ToList());
.
public async Task<IEnumerable<AllWorkersFilterDto>> GetData()
{
//
var DbData = _userManager.Users.Select(c => new AllWorkersFilterDto
{
Id = c.Id.ToString(),
Name = c.UserName,
LastName = c.UserName,
Email = c.Email,
Role = "User",
}).ToListAsync().Result;
var data = DbData.AsQueryable();
var model = new { Name = "m H", GPA = "A" };
if (!string.IsNullOrWhiteSpace(model.Name))
data = data.Where(x => x.Name.ToLower().Contains(model.Name.ToLower()));
//the following is used to check whether the data contains value or not.
var result = data.ToList();
var count = result.Count;
return await Task.FromResult(data.ToList());
}
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion