/// <summary> /// Save entity'propertity which is not null /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> public void SetModifyColumnsWithOutNull<T>(T entity) where T : EntityObject { ObjectStateEntry stateEntry = null; bool isPresent = _ctx.ObjectStateManager.TryGetObjectStateEntry(entity, out stateEntry); if (stateEntry == null) _ctx.AttachTo(typeof(T).Name, entity);}错误:An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.说明:我是把上下文放在线程的CallContext里面了,在调用这个方法之前,我查询过该对象,修改之后,调用这个方法进行更新,结果报上述错误。疑问:既然从上下文中获取不到对象状态,那附加对象为何还是出错呢?请大虾们赐教小弟
- 2 回答
- 0 关注
- 477 浏览
添加回答
举报
0/150
提交
取消