using (DB.HZJY_CGOAContext myContext = new DB.HZJY_CGOAContext())
{
var context = myContext.Busi_ProjectStandItem;
foreach (DB.Busi_ProjectStandItem psdelmodel in listDelProjectStandItem)
{
context.Remove(curmodel);
}
foreach (DB.Busi_ProjectStandItem psaddmodel in listAddProjectStandItem)
{
context.Add(psaddmodel);
}
myContext.Entry(model).State = EntityState.Modified;
myContext.SaveChanges();
_nResult = 1;
}
解决办法
using (DB.HZJY_CGOAContext myContext = new DB.HZJY_CGOAContext())
{
var context = myContext.Busi_ProjectStandItem;
foreach (DB.Busi_ProjectStandItem psdelmodel in listDelProjectStandItem)
{
var curmodel=myContext.Busi_ProjectStandItem.Attach(psdelmodel);
context.Remove(curmodel);
}
foreach (DB.Busi_ProjectStandItem psaddmodel in listAddProjectStandItem)
{
context.Add(psaddmodel);
}
myContext.Entry(model).State = EntityState.Modified;
myContext.SaveChanges();
_nResult = 1;
}
浙公网安备 33010602011771号