简体   繁体   中英

Nested collections - issue,when namespace of entity has been changed

I use RavenDb for my portal. Example of Question document below:

{
  "CreatedOn": "2012-07-12T09:40:44.7514005Z",
  "CreatedBy": {
    "DisplayName": "Kamil",
  },
  "Subject": "My q",
  "Content": "My q content",
  "Tags": [
    "myQ"
  ],
  "Answers": {
    "$type": "System.Collections.ObjectModel.Collection`1[[QA.Core.Entities.Answer, QA.Core]], mscorlib",
    "$values": [
      {
        "CreatedOn": "2012-07-12T09:42:06.9852492Z",
        "CreatedBy": {
          "DisplayName": "Kamil",
        },
        "ModifiedOn": "2012-07-12T09:43:07.8442347Z",
        "ModifiedBy": {
          "DisplayName": "Kamil",
        },
        "Content": "My answer.",
        "IdNumber": 1,
        "Supporters": {
          "$type": "System.Collections.ObjectModel.Collection`1[[QA.Core.Entities.User, QA.Core]], mscorlib",
          "$values": []
        },
        "IsOfficial": true,
        "AttachmentHeaders": []
      }
    ]
  },
  "NumberOfViews": 3,
  "Supporters": {
    "$type": "System.Collections.ObjectModel.Collection`1[[QA.Core.Entities.User, QA.Core]], mscorlib",
    "$values": []
  },
  "NotificationEmails": [],
  "AttachmentHeaders": [],
  "LastAnswerId": 1
}

After big refactoring namespace of Question class has changed. In document metadata (in raven) that change was detected and it's ok. But what about nested collections like:

  "Supporters": {
    "$type": "System.Collections.ObjectModel.Collection`1[[QA.Core.Entities.User, QA.Core]], mscorlib",
    "$values": []
  },

? That piece of document generates error when i'm trying to get it from app level. Problem disappears when i change it to:

  "Supporters": [],

but it's not a solution if i have to do that action on 200 documents.

Is any way to do that automatically?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM