aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/UserRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Data/Repositories/UserRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/UserRepository.cs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs
index f5a074b..1508947 100644
--- a/src/DevHive.Data/Repositories/UserRepository.cs
+++ b/src/DevHive.Data/Repositories/UserRepository.cs
@@ -33,6 +33,7 @@ namespace DevHive.Data.Repositories
{
return this._context
.Set<User>()
+ .Include(x => x.Roles)
.AsNoTracking()
.AsEnumerable();
}
@@ -41,13 +42,17 @@ namespace DevHive.Data.Repositories
{
return await this._context
.Set<User>()
- .FindAsync(id);
+ .Include(x => x.Roles)
+ // To also return the roles, you need to include the roles table,
+ // but then you loose FindAsync, because there is id of role and id of user
+ .FirstOrDefaultAsync(x => x.Id == id);
}
public async Task<User> GetByUsername(string username)
{
return await this._context
.Set<User>()
+ .Include(u => u.Roles)
.FirstOrDefaultAsync(x => x.UserName == username);
}