This commit is contained in:
2020-09-27 22:16:57 +02:00
parent 1811ea5a1a
commit 5c86727baa
9 changed files with 55 additions and 11 deletions

View File

@ -37,13 +37,20 @@ namespace UserService.DatabaseLayer.Repositories
public virtual async Task<IReadOnlyList<T>> GetAllAsync(Expression<Func<T, 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)
.WhereOrDefault(predicate)
.ToListAsync(token)
.ConfigureAwait(false);
}
public virtual async Task<T?> GetAsync(Expression<Func<T, bool>> predicate, CancellationToken token = default)
{
await using var db = new UserServiceDbContext();
return await Context(db).Include(x => x.Parent).FirstOrDefaultAsync(predicate, token).ConfigureAwait(false);
return await Context(db)
.Include(x => x.Parent)
.FirstOrDefaultAsync(predicate, token)
.ConfigureAwait(false);
}
public virtual async Task<bool> UpdateAsync(T entity, CancellationToken token = default)
{