【发布时间】:2013-12-14 13:57:25
【问题描述】:
给出下面列出的模型,我想使用 MongoDb.Driver.Serialization 为属性 PostId 创建一个 IndexKey。
public class Post
{
public ObjectId Id { get; private set; }
public string Title { get; set; }
public string Body { get; set; }
public IList<Comment> Comments { get; set; }
}
public class Comment
{
public ObjectId Id { get; private set; }
public string Email { get; set; }
public string Body { get; set; }
public ObjectId PostId { get; set; }
public Post Post { get; set; }
}
我想使用类似的东西
MongoDB.Bson.Serialization.BsonClassMap.RegisterClassMap<Post>(p =>
{
p.MapIdField(f => f.Id);
});
【问题讨论】:
-
没有。人们已经通过几种不同的方式解决了它:stackoverflow.com/questions/7823187/…
标签: c# .net mongodb mongodb-.net-driver