Example #1
0
 public T Get(Guid id)
 {
     using (var db = new SeuVizinhoContext())
     {
         return db.Set<T>().SingleOrDefault(x => x.Id == id);
     }
 }
Example #2
0
 public IEnumerable<T> GetAll(Func<T, bool> predicate)
 {
     using (var db = new SeuVizinhoContext())
     {
         return db.Set<T>().Where(predicate).ToArray();
     }
 }        
Example #3
0
 public T Get(Func<T, bool> predicate)
 {
     using (var db = new SeuVizinhoContext())
     {
         return db.Set<T>().FirstOrDefault(predicate);
     }
 }
Example #4
0
 public void Remove(T entity)
 {
     using (var db = new SeuVizinhoContext())
     {
         db.Entry(entity).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Example #5
0
 public void Modify(T entity)
 {
     using (var db = new SeuVizinhoContext())
     {
         db.Entry(entity).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #6
0
 public void Add(T entity)
 {
     using (var db = new SeuVizinhoContext())
     {
         db.Add<T>(entity);
         db.SaveChanges();
     }
 }