Ejemplo n.º 1
0
 public List <T> GetRange()
 {
     using (var context = new teCorpContext())
     {
         var records = context.Set <T>().ToList();
         return(records);
     }
 }
Ejemplo n.º 2
0
 public void Remove(T record)
 {
     using (var context = new teCorpContext())
     {
         context.Entry(record).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo 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);
     }
 }
Ejemplo 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);
     }
 }
Ejemplo n.º 5
0
 public void Add(T record)
 {
     using (var context = new teCorpContext())
     {
         context.Entry(record).State = EntityState.Added;
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public void Update(T record)
 {
     using (var context = new teCorpContext())
     {
         context.Entry(record).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo 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);
         }
     }));
 }
Ejemplo 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);
         }
     }));
 }
Ejemplo 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);
         }
     }));
 }
Ejemplo 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();
     }
 }
Ejemplo 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);
 }
Ejemplo 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);
 }
Ejemplo 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);
 }