public T Get(Expression <Func <T, bool> > condition)
 {
     using (var context = new AWSContext())
     {
         var record = context.Set <T>().FirstOrDefault(condition);
         return(record);
     }
 }
 public async Task <List <T> > GetRangeAsync(CancellationToken token)
 {
     return(await Task.Run(async() =>
     {
         using (var context = new AWSContext())
         {
             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 AWSContext())
         {
             return await context.Set <T>().Where(condition).ToListAsync(token).ConfigureAwait(false);
         }
     }));
 }
 public async Task AddRangeAsync(List <T> records, CancellationToken token)
 {
     await Task.Run(async() =>
     {
         using (var context = new AWSContext())
         {
             context.Set <T>().AddRange(records);
             await context.SaveChangesAsync(token).ConfigureAwait(false);
         }
     }, token);
 }
 public async Task <int> AddAsync(T record, CancellationToken token)
 {
     return(await Task.Run(async() =>
     {
         using (var context = new AWSContext())
         {
             context.Set <T>().Add(record);
             return await context.SaveChangesAsync(token).ConfigureAwait(false);
         }
     }, token));
 }
 public List <T> GetRange(Expression <Func <T, bool> > condition)
 {
     if (condition == null)
     {
         return(GetRange());
     }
     using (var context = new AWSContext())
     {
         var records = context.Set <T>().Where(condition).ToList();
         return(records);
     }
 }