摘要:
publicT AddEntity(T entity){//EF4.0的写法添加实体//db.CreateObjectSet().AddObject(entity);//EF5.0的写法db.Entry(entity).State =EntityState.Added;//下面的写法统一db.SaveChanges();returnentity;}publicboolUpdateEntity(T entity){//EF4.0的写法//db.CreateObjectSet().Addach(entity);//db.ObjectStateManager.ChangeObjectState(en 阅读全文