In a project I am working on, In some of the repositories, async / await is not used in the data layer. I believe this can cause performance issues as I believe it is missed.
public Task<List<Role>> GetRolesByClaimValue(Guid tenantId, string claimType, CancellationToken cancellationToken = default)
{
return _dbContext.GLSRoleClaims.Include(t => t.Role).Where(t => (t.TenantId == null || t.TenantId == tenantId) && t.ClaimType == claimType).Select(t => t.Role!).ToListAsync(cancellationToken);
}
Another Repo
public Task<bool> IsInvited(Guid tenantId, Guid userId, CancellationToken cancellationToken = default) => _dbContext.TenantInvitations.AnyAsync(t => t.UserId == userId && t.TenantId == tenantId, cancellationToken: cancellationToken);
Is it ok to not be added ? as I searched on the internet and read about “async elision” or “async pass-through” and it is sometimes useful in performance
I am confused when to use it and when don’t.
I am trying to know when should not using async/await is good