-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
AccountDataService could inherit from NonQueryDataService thereby removing the need to write out or have to explicitly delegate functionality to NonQueryDataService... here's what I mean:
public class AccountDataService : NonQueryDataService<Account>, IDataService<Account>
{
private readonly SimpleTraderDbContextFactory _contextFactory;
public AccountDataService(SimpleTraderDbContextFactory contextFactory) : base(contextFactory)
{
_contextFactory = contextFactory;
}
public async Task<IEnumerable<Account>> GetAll()
{
await using var context = _contextFactory.CreateDbContext(new[] {""});
var list = await context.Accounts.Include(x => x.AssetTransactions).Include(x => x.AccountHolder)
.ToListAsync();
return list;
}
public async Task<Account> Get(int id)
{
await using var context = _contextFactory.CreateDbContext(new[] {""});
var entity = await context.Accounts.Include(x => x.AssetTransactions).Include(x => x.AccountHolder)
.FirstOrDefaultAsync(x => x.Id == id);
return entity;
}
}
Twodio
Metadata
Metadata
Assignees
Labels
No labels