/// <summary> /// 添加实例 /// </summary> /// <param name="student"></param> public void Insert(person_test p)//可以添加一个entity 参数 { using (var entity = new ccf02Entities()) { entity.person_test.Add(p); entity.SaveChanges(); } }
/// <summary> /// 修改实例 /// </summary> /// <param name="model"></param> public void Edit(person_test model) { using (var entity = new ccf02Entities()) { entity.Entry(model).State = EntityState.Modified; entity.SaveChanges(); } }
/// <summary> /// 删除某一条数据 /// </summary> /// <param name="id"></param> public void Deleted(int id) //添加两个参数entity & table { using (var entity = new ccf02Entities()) { person_test p = new person_test() { idperson_test = id }; var model = entity.person_test.FirstOrDefault(w => w.idperson_test == id); entity.person_test.Remove(model); entity.SaveChanges(); } }