2016-02-03 29 views
0

我有這樣一個烏鴉的數據庫文件結構:RavenDB:有沒有辦法從數據庫中刪除混凝土領域?

{"Title":"abc", 
"User":{"$type": "IOM.Server.Data", "Mail":...etc}, 
"Content": [ 
    { 
     "Additional": { 
     "Title": "abc", 
     "$type": "IOM.Server.Data" 
     } 
    }] 
} 

在Visual Studio(C#)我得到一個錯誤 「無法加載程序集 'IOM.Server.Data'」。

我不能讀取這個值作爲字符串,因爲我不能有一個名爲「$ type」的變量。

現在我必須將用戶和內容讀取爲對象類型,然後轉換爲Json,然後從Json對象中獲取信息。如果我可以從數據庫中的任何地方(用戶,內容 - 附加)中刪除所有這些字段,將會更容易,因爲我不需要它們。有沒有辦法做到這一點?解決這個問題是否正確?

回答

1

如果您在工作室中看到$ type,這意味着您可能已經通過擴展您的道具'User'和'Additional'的基類的類實例化'User'和'Additional'。 順便說一句,如果你想刪除$類型你可以使用補丁:

documentStore.DatabaseCommands.Patch("yourDocId/1", 
        new[] 
        { 
         new PatchRequest 
         { 
          Type = PatchCommandType.Modify, 
          Name = "User", 
          AllPositions = true, 
          Nested = new [] 
          {         
           new PatchRequest 
           { 
             Type = PatchCommandType.Unset, 
             Name = "$type" 
           }          
          } 
         }, 
         new PatchRequest 
         { 
          Type = PatchCommandType.Modify, 
          Name = "Content", 
          AllPositions = true, 
          Nested = new [] 
          { 
           new PatchRequest 
           { 
            Type = PatchCommandType.Modify, 
            Name = "Additional", 
            AllPositions = true, 
            Nested = new [] 
            { 
             new PatchRequest 
             { 
              Type = PatchCommandType.Unset, 
              Name = "$type" 
             } 
            } 
           } 
          } 
         } 
        }); 

希望這有助於

+0

是。你是對的。我在客戶的服務器上找到'IOM.Server.Data'程序集,它包含我需要的所有東西。基本上,它解決了一切。謝謝 – anindis