使用using创建对象,例如:
using (JPKLEntities jpklDb = new JPKLEntities())
{
CATEGORY category = new CATEGORY() { CATEGORY_ID = id };
jpklDb.Entry<CATEGORY>(category).State = System.Data.EntityState.Deleted;
return jpklDb.SaveChanges();
}
时间: 2024-10-12 14:40:15