MongoDB C#驱动程序使用动态对象进行序列化

我有一个看起来像这样的模型:

public class Record { public Record() { Created = DateTime.Now; } public string Id { get; set; } public string ApplicationId { get; set; } public Dictionary Values { get; set; } public DateTime Created { get; set; } } 

使用MongoDB C#驱动程序存储在MongoDB中。 当我做以下事情时,这很有效:

 { 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的经验?

更新: v2.0驱动程序现在支持dynamic


你不能使用dynamicMongoDB的C#驱动程序。 这是关于它的jira票 。

从描述:

我们还没有确定哪个版本可以添加对C#动态类型的支持。 此票证是您可以评论该function的可取性和/或投票的地方。