Пример #1
0
 public static void Add(TEntity entity)
 {
     using (var context = new TestGeorgeContext())
     {
         context.Set <TEntity>().Add(entity);
         context.SaveChanges();
     }
 }
Пример #2
0
 public static TEntity Update(TEntity toUpdate, Expression <Func <TEntity, bool> > whereClause)
 {
     using (var context = new TestGeorgeContext())
     {
         var result = context.Set <TEntity>().SingleOrDefault(whereClause);
         context.Entry(result).CurrentValues.SetValues(toUpdate);
         context.SaveChanges();
         return(toUpdate);
     }
 }
Пример #3
0
 public static void Delete(Expression <Func <TEntity, bool> > whereClause)
 {
     using (var context = new TestGeorgeContext())
     {
         var entity = SingleOrDefault(whereClause);
         if (entity != null)
         {
             var result = context.Set <TEntity>().Remove(entity);
             context.SaveChanges();
         }
     }
 }