2
我想将Guid列表存储为MongoDB中的字符串列表。对于单个的Guid我使用以下属性:将MongoDb中的Guids列表存储为字符串列表
[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的聚合框架http://stackoverflow.com/a/11952062/ – chridam 2014-10-29 11:57:52
@chridam从来没有这样的字符串。你链接的是用2.6之前的二进制值来描述一个限制。 – JohnnyHK 2014-10-29 12:25:38