Esempio n. 1
0
 public void Delete(TEntity entity)
 {
     using (var Context = new hackathon_customEntities())
     {
         if (Context.Entry(entity).State == EntityState.Detached)
         {
             Context.Set <TEntity>().Attach(entity);
         }
         Context.Set <TEntity>().Remove(entity);
         Context.SaveChanges();
     }
 }
Esempio n. 2
0
 public TEntity First(Expression <Func <TEntity, bool> > predicate)
 {
     using (var Context = new hackathon_customEntities())
     {
         return(Context.Set <TEntity>().First(predicate));
     }
 }
Esempio n. 3
0
 public TEntity First()
 {
     using (var Context = new hackathon_customEntities())
     {
         return(Context.Set <TEntity>().First());
     }
 }
Esempio n. 4
0
 public TEntity GetById(object id)
 {
     using (var Context = new hackathon_customEntities())
     {
         return(Context.Set <TEntity>().Find(id));
     }
 }
Esempio n. 5
0
 public List <TEntity> GetAll()
 {
     using (var Context = new hackathon_customEntities())
     {
         return(Context.Set <TEntity>().ToList());
     }
 }
Esempio n. 6
0
 public void Insert(TEntity entity)
 {
     using (var Context = new hackathon_customEntities())
     {
         Context.Set <TEntity>().Add(entity);
         Context.SaveChanges();
     }
 }
Esempio n. 7
0
 public List <TEntity> GetAll(Expression <Func <TEntity, bool> > predicate)
 {
     using (var Context = new hackathon_customEntities())
     {
         return(Context.Set <TEntity>()
                .Where(predicate).ToList());
     }
 }
Esempio n. 8
0
 public void Update(TEntity entity)
 {
     using (var Context = new hackathon_customEntities())
     {
         Context.Set <TEntity>().Attach(entity);
         Context.Entry(entity).State = EntityState.Modified;
         Context.SaveChanges();
     }
 }