public List <T> GetRange() { using (var context = new teCorpContext()) { var records = context.Set <T>().ToList(); return(records); } }
public void Remove(T record) { using (var context = new teCorpContext()) { context.Entry(record).State = EntityState.Deleted; context.SaveChanges(); } }
public List <T> GetRange(Expression <Func <T, bool> > condition) { using (var context = new teCorpContext()) { var records = context.Set <T>().Where(condition).ToList(); return(records); } }
public T Get(Expression <Func <T, bool> > condition) { using (var context = new teCorpContext()) { var record = context.Set <T>().FirstOrDefault(condition); return(record); } }
public void Add(T record) { using (var context = new teCorpContext()) { context.Entry(record).State = EntityState.Added; context.SaveChanges(); } }
public void Update(T record) { using (var context = new teCorpContext()) { context.Entry(record).State = EntityState.Modified; context.SaveChanges(); } }
public async Task <List <T> > GetRangeAsync(CancellationToken token) { return(await Task.Run(async() => { using (var context = new teCorpContext()) { return await context.Set <T>().ToListAsync(token).ConfigureAwait(false); } })); }
public async Task <List <T> > GetRangeAsync(Expression <Func <T, bool> > condition, CancellationToken token) { return(await Task.Run(async() => { using (var context = new teCorpContext()) { return await context.Set <T>().Where(condition).ToListAsync(token).ConfigureAwait(false); } })); }
public async Task <T> GetAsync(Expression <Func <T, bool> > condition, CancellationToken token) { return(await Task.Run(async() => { using (var context = new teCorpContext()) { return await context.Set <T>().FirstOrDefaultAsync(token).ConfigureAwait(false); } })); }
public void RemoveRange(List <T> records) { using (var context = new teCorpContext()) { foreach (var record in records) { context.Entry(record).State = EntityState.Deleted; } context.SaveChanges(); } }
public async Task RemoveAsync(T record, CancellationToken token) { await Task.Run(async() => { using (var context = new teCorpContext()) { context.Entry(record).State = EntityState.Deleted; await context.SaveChangesAsync(token).ConfigureAwait(false); } }, token); }
public async Task AddRangeAsync(List <T> records, CancellationToken token) { await Task.Run(async() => { using (var context = new teCorpContext()) { context.Set <T>().AddRange(records); await context.SaveChangesAsync(token).ConfigureAwait(false); } }, token); }
public async Task UpdateRangeAsync(List <T> records, CancellationToken token) { await Task.Run(async() => { using (var context = new teCorpContext()) { foreach (var record in records) { context.Entry(record).State = EntityState.Modified; } await context.SaveChangesAsync(token).ConfigureAwait(false); } }, token); }