我有一個模型,它看起來像:與動態對象的MongoDB C#驅動程序序列化
public class Record
{
public Record()
{
Created = DateTime.Now;
}
public string Id { get; set; }
public string ApplicationId { get; set; }
public Dictionary<string, dynamic> Values { get; set; }
public DateTime Created { get; set; }
}
一個儲存在MongoDB的使用MongoDB的C#驅動程序。
{
applicationId: "52f52db8008a280f583c9ff6",
values: {
"52f9410a324e68055f39f8c0": 245234
"52f941096d82a531e700e56b": "sdfasdf"
"52fa4a96e0b2e0d4e61d0a03": "52fa4a9b91c477e367ab99e6"
}
}
,但是當我嘗試添加像一個字符串數組:
{
applicationId: "52f52db8008a280f583c9ff6",
values: {
"52f9410a324e68055f39f8c0": 245234
"52f941096d82a531e700e56b": "sdfasdf"
"52fa4a96e0b2e0d4e61d0a03": "52fa4a9b91c477e367ab99e6"
"52fa85ea16f04a6151e4ea51": [ "52fa85f2d2ffa4cbdcf538e8", "52fa85f205505f671f3d0d7b"]
}
}
它給了我下面的錯誤,當我嘗試做了一個GET,當我做這樣的事情的偉大工程文件:
An exception of type 'System.IO.FileFormatException' occurred in MongoDB.Driver.dll but was not handled in user code
Additional information: An error occurred while deserializing the Values property of class API.Models.Record.Record: Cannot create an abstract class.
,如果我看它的數據庫保存,但其真正時髦的期待:
任何人都有動態和mongo的經驗嗎?
這是哪個用戶界面?對於mongo ... – i3arnon
robomongo - http://robomongo.org/ – amcdnl
此外,你意識到序列化只是問題的一半,反序列化將是非常艱難的,如果不是不可能的話。 – i3arnon