使用MongoDB C#映射私有支持字段
我正在尝试在MongoDB中映射一个私有支持字段。
我的模型看起来像:
public class Competitor { private IList _competitorBests; public virtual int CompetitorId { get; set; } public virtual string Name { get { if (Type == "Team") return TeamName; return FirstName + " " + LastName; } } public virtual IEnumerable CompetitorBests { get { return _competitorBests.ToArray(); } } }
我基本上试图将_competitorBests映射为CompetitorBests(存在于mongo中的文档中)
注意:这个模型由NHibernate共享(因此是virtual
)
我在文档中看不到任何明显的东西。
我该怎么做?
这样就可以了:
BsonClassMap.RegisterClassMap(cm => { cm.AutoMap(); cm.MapField("_competitorBests").SetElementName("CompetitorBests"); });