Esempio n. 1
0
 public List <T> GetRange()
 {
     using (var context = new teCorpContext())
     {
         var records = context.Set <T>().ToList();
         return(records);
     }
 }
Esempio n. 2
0
 public void Remove(T record)
 {
     using (var context = new teCorpContext())
     {
         context.Entry(record).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Esempio n. 3
0
 public List <T> GetRange(Expression <Func <T, bool> > condition)
 {
     using (var context = new teCorpContext())
     {
         var records = context.Set <T>().Where(condition).ToList();
         return(records);
     }
 }
Esempio n. 4
0
 public T Get(Expression <Func <T, bool> > condition)
 {
     using (var context = new teCorpContext())
     {
         var record = context.Set <T>().FirstOrDefault(condition);
         return(record);
     }
 }
Esempio n. 5
0
 public void Add(T record)
 {
     using (var context = new teCorpContext())
     {
         context.Entry(record).State = EntityState.Added;
         context.SaveChanges();
     }
 }
Esempio n. 6
0
 public void Update(T record)
 {
     using (var context = new teCorpContext())
     {
         context.Entry(record).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 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);
         }
     }));
 }
Esempio n. 8
0
 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);
         }
     }));
 }
Esempio n. 9
0
 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);
         }
     }));
 }
Esempio n. 10
0
 public void RemoveRange(List <T> records)
 {
     using (var context = new teCorpContext())
     {
         foreach (var record in records)
         {
             context.Entry(record).State = EntityState.Deleted;
         }
         context.SaveChanges();
     }
 }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
 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);
 }
Esempio n. 13
0
 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);
 }