Example #1
0
 public virtual bool Exists(Func <T, bool> where)
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <T>()
                .Any(where));
     }
 }
Example #2
0
 public Ordem GetOne(Func <Ordem, bool> where)
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <Ordem>()
                .AsNoTracking()
                .FirstOrDefault(where));
     }
 }
Example #3
0
 public IList <Ordem> GetAll()
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <Ordem>()
                .AsNoTracking()
                .ToList());
     }
 }
Example #4
0
 public virtual IList <T> GetAll()
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <T>()
                .AsNoTracking()
                .ToList());
     }
 }
Example #5
0
 public virtual T GetOne(Func <T, bool> where)
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <T>()
                .AsNoTracking()
                .FirstOrDefault(where));
     }
 }
Example #6
0
 public IList <Ordem> Get(Func <Ordem, bool> where)
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <Ordem>()
                .AsNoTracking()
                .Where(where)
                .ToList());
     }
 }
Example #7
0
 public virtual IList <T> Get(Func <T, bool> where)
 {
     using (var context = new BtgDbContext())
     {
         return(context
                .Set <T>()
                .AsNoTracking()
                .Where(where)
                .ToList());
     }
 }
Example #8
0
 public bool TryAdd(params Ordem[] items)
 {
     using (var context = new BtgDbContext())
     {
         foreach (var item in items)
         {
             context.Entry(item).State = EntityState.Added;
         }
         context.SaveChanges();
         return(true);
     }
 }
Example #9
0
 public virtual bool TryDelete(params T[] items)
 {
     using (var context = new BtgDbContext())
     {
         try
         {
             foreach (var item in items)
             {
                 context.Entry(item).State = EntityState.Deleted;
             }
             context.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }