0

不确定这是否是一个错误,但是:当您使用 observable 扩展类型时,它也会在saveChanges中序列化。这使得EFContextProvider无法删除实体。

发送的json示例:

{"entities": [{
    "Id":1015,
    "Key":"3",
    "Value":"2",
    "undefined":"",
    "entityAspect":{
        "entityTypeName":"Setting:#Settings_Beeze.Models",
        "entityState":"Deleted",
        "originalValuesMap":{"isBeingEdited":false},
        "autoGeneratedKey":{
             "propertyName":"Id",
             "autoGeneratedKeyType":"Identity"}}}],
"saveOptions":{
    "allowConcurrentSaves":false}}

isBeingEdited - 是客户端可观察的,不应该发送到服务器(我认为是这样)。它还生成未定义字段(它不是扩展对象的一部分,它来自任何地方)。

因此, EFContextProvider中的服务器端代码因NullReferenceException而失败,这是堆栈跟踪:

at Breeze.WebApi.EFContextProvider`1.SetPropertyValue(Object entity, String propertyName, Object value)
at Breeze.WebApi.EFContextProvider`1.<>c__DisplayClassd.<RestoreOriginal>b__c(KeyValuePair`2 kvp)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at Breeze.WebApi.EFContextProvider`1.RestoreOriginal(EntityInfo entityInfo)
at Breeze.WebApi.EFContextProvider`1.<ProcessAllDeleted>b__6(EFEntityInfo entityInfo)
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at Breeze.WebApi.EFContextProvider`1.ProcessAllDeleted(List`1 deletedEntities)
at Breeze.WebApi.EFContextProvider`1.SaveChangesCore(Dictionary`2 saveMap)
at Breeze.WebApi.ContextProvider.SaveChanges(JObject saveBundle)
at Settings_Beeze.Controllers.DataController.SaveChanges(JObject saveBundle) in s:\Projects\Else\Settings Beeze\Settings Beeze\Controllers\DataController.cs:line 35
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)

作为修复想法:unwrapOriginalValues应该检查属性是否未映射并继续下一个而不将其写入答案。

  • 将问题从 GitHub 移至 SO
4

1 回答 1

1

对我来说听起来像是一个错误。我们会跳上去的。

于 2013-03-19T20:55:21.487 回答