【发布时间】:2014-10-29 22:43:50
【问题描述】:
我想将 Guid 列表存储为 MongoDB 中的字符串列表。对于单个 Guid,我使用以下属性:
[BsonRepresentation(BsonType.String)]
public Guid GuidId{ get; set; }
是否有一个属性可以做同样的事情:
public List<Guid> GuidIdList { get; set; }
我发现了如何使用约定来做到这一点,但我真的很喜欢用属性来做到这一点:
How can I tell the MongoDB C# driver to store all Guids in string format?
【问题讨论】:
-
将 GUID 存储为字符串的一个缺点是不能使用 mongodb 聚合框架stackoverflow.com/a/11952062
-
@chridam 字符串从来都不是这样。您链接到的是描述 2.6 之前二进制值的限制。