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

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

本文介绍了1.2.1未映射的属性不应序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定是否是错误,但是:当您具有可观察的扩展类型时,它也会在 saveChanges 中进行序列化.这使得 EFContextProvider 在删除实体时失败.

Not sure if it is a bug, but:When you have extended type with observable it is also serialized in saveChanges. This makes EFContextProvider to fail on deleting entities.

发送的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 (这不是扩展对象的一部分,它无处不在).

isBeingEdited - is client-side observable, and shouldn't be sent to server (I think so).It also generates field undefined (which is not part of extended object, it comes from nowhere).

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

So server-side code fails in EFContextProvider with NullReferenceException, here is stack trace:

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 应该检查属性是否未映射,并继续进行下一个操作,直到将其写入答案为止.

As fix idea: unwrapOriginalValues should check whether property is unmapped and continue to the next one wihout writing it to the answer.

  • 将问题从GitHub移至SO

推荐答案

听起来像是我的错误.我们会跳上它.

Sounds like a bug to me. We'll jump on it.

这篇关于1.2.1未映射的属性不应序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 21:15