Me.ChangeSet.GetOriginal,对象引用未设置为对象的实例

时间:2010-12-16 10:15:57

标签: asp.net vb.net entity-framework-4 ria

嘿,我在使用域服务,实体框架和asp.net更新记录时遇到问题。

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


 Line 257:            }
Line 258:        Me.ObjectContext.OrderStatusHistories.AddObject(_orderStatusHistory)
Line 259:        Me.ObjectContext.Orders.AttachAsModified(currentOrder, Me.ChangeSet.GetOriginal(currentOrder))
Line 260:    End Sub
Line 261:

订单是在数据库中提交的,有谁知道这里发生了什么?

1 个答案:

答案 0 :(得分:0)

原来,变更集为空。所以在我的代码中添加了一个if changeset不为null,如果没有变更集,我不需要运行代码。

相关问题