예제 #1
0
 public IEnumerable <TEntity> GetAll()
 {
     using (var context = new NorthwindContext())
     {
         return(context.Set <TEntity>().Take(100).ToList());
     }
 }
예제 #2
0
 public TEntity GetById(int id)
 {
     using (var context = new NorthwindContext())
     {
         return(context.Set <TEntity>().Find(id));
     }
 }
예제 #3
0
 public TEntity Add(TEntity entity)
 {
     using (var context = new NorthwindContext())
     {
         var createdEntity = context.Set <TEntity>().Add(entity);
         context.SaveChanges();
         return(createdEntity);
     }
 }