more code behind. and more orga power

This commit is contained in:
2020-07-30 22:35:22 +02:00
parent 114b52c963
commit 61b32841bd
12 changed files with 231 additions and 91 deletions

View File

@ -12,14 +12,14 @@ namespace UserService.DatabaseLayer.Repository
{
public class BaseRepository<T> where T : Node
{
private readonly Func<UserServiceDbContext, DbSet<T>> _context;
protected readonly Func<UserServiceDbContext, DbSet<T>> _context;
protected BaseRepository(Func<UserServiceDbContext, DbSet<T>> context)
{
_context = context;
}
public async Task<IReadOnlyList<T>> GetAllAsync(CancellationToken token = default)
public virtual async Task<IReadOnlyList<T>> GetAllAsync(CancellationToken token = default)
{
await using var db = new UserServiceDbContext();
return await _context(db).Include(x => x.Parent).ToListAsync(token);