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