1.2.1未映射的属性不应序列化

时间:2013-03-19 19:01:42

标签: breeze

不确定是否是错误,但是: 当您具有带有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 - 是客户端可观察的,不应该发送到服务器(我想是这样)。 它还会生成字段 undefined (它不是扩展对象的一部分,它来自任何地方)。

所以服务器端代码在 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

1 个答案:

答案 0 :(得分:1)

对我来说听起来像个错误。我们会跳上它。