Exemplo n.º 1
0
 public void Delete<T>(T t) where T : class
 {
     using (codeFirstEntities context = new codeFirstEntities())
     {
         context.Set<T>().Remove(t);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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;
     }
 }