Example #1
0
 public void Delete<T>(T t) where T : class
 {
     using (codeFirstEntities context = new codeFirstEntities())
     {
         context.Set<T>().Remove(t);
     }
 }
Example #2
0
 //得到单个实体信息
 public T GetInfo<T>(Expression<Func<T, bool>> express) where T : class
 {
     using (codeFirstEntities context = new codeFirstEntities())
     {
         return context.Set<T>().FirstOrDefault<T>(express);
     }
 }
Example #3
0
 //得到单个实体信息
 public List<T> GetList<T>(Expression<Func<T, bool>> express, int PageIndex, int PageSize) where T : class
 {
     using (codeFirstEntities context = new codeFirstEntities())
     {
         return context.Set<T>().Where(express).Skip(PageSize * PageSize).Take(PageSize).ToList();
     }
 }
Example #4
0
 public T Insert<T>(T t) where T : class
 {
     using (codeFirstEntities entity = new codeFirstEntities())
     {
         entity.Set<T>().Add(t);
         entity.SaveChanges();
         return t;
     }
 }