refactoring: reorganize code
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using UserService.DatabaseLayer.DataModels;
|
||||
using UserService.Infrastructure.DataModels;
|
||||
|
||||
@ -18,8 +19,20 @@ namespace UserService.DatabaseLayer.Repositories
|
||||
public override async Task<IReadOnlyList<SecurityGroup>> GetAllAsync(Expression<Func<SecurityGroup, bool>>? predicate = null, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db).Include(x => x.Parent).WhereOrDefault(predicate).ToListAsync(token).ConfigureAwait(false);
|
||||
return await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.Include(x => x.Members)
|
||||
.WhereOrDefault(predicate)
|
||||
.ToListAsync(token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public override async Task<SecurityGroup?> GetAsync(Expression<Func<SecurityGroup, bool>> predicate, CancellationToken token = default)
|
||||
{
|
||||
await using var db = new UserServiceDbContext();
|
||||
return await Context(db)
|
||||
.Include(x => x.Parent)
|
||||
.Include(x => x.Members)
|
||||
.FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user