示例#1
0
 public IEnumerable <T> GetAll()
 {
     using (ToTheListContext db = new ToTheListContext())
     {
         return(db.Set <T>().ToList());
     }
 }
示例#2
0
 public T GetById(int id)
 {
     using (ToTheListContext db = new ToTheListContext())
     {
         return(db.Set <T>().Find(id));
     }
 }
示例#3
0
 public void Create(T entity)
 {
     using (ToTheListContext db = new ToTheListContext())
     {
         db.Set <T>().Add(entity);
         db.SaveChanges();
     }
 }