1.2.1 unmapped properties shouldn't be serialized [closed]

ⅰ亾dé卋堺 提交于 2020-01-07 06:29:45

问题


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.

Example of json sent:

{"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 - 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).

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)

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

  • moved issue from GitHub to SO

回答1:


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



来源:https://stackoverflow.com/questions/15508233/1-2-1-unmapped-properties-shouldnt-be-serialized

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!