C# 使用MongoDB C映射私有支持字段#
我正在尝试在MongoDB中映射一个私有支持字段。C# 使用MongoDB C映射私有支持字段#,c#,mongodb,mongodb-.net-driver,C#,Mongodb,Mongodb .net Driver,我正在尝试在MongoDB中映射一个私有支持字段。 我的模型看起来像: public class Competitor { private IList<CompetitorBest> _competitorBests; public virtual int CompetitorId { get; set; } public virtual string Name { get { if (Typ
我的模型看起来像:
public class Competitor
{
private IList<CompetitorBest> _competitorBests;
public virtual int CompetitorId { get; set; }
public virtual string Name
{
get
{
if (Type == "Team")
return TeamName;
return FirstName + " " + LastName;
}
}
public virtual IEnumerable<CompetitorBest> CompetitorBests
{
get { return _competitorBests.ToArray(); }
}
}
公共级竞争对手
{
私人IList_竞争对手测试;
公共虚拟整数竞争ID{get;set;}
公共虚拟字符串名
{
得到
{
如果(类型=“团队”)
返回团队名称;
返回FirstName+“”+LastName;
}
}
公共虚拟可数竞技场
{
获取{return_competitorBests.ToArray();}
}
}
我基本上是在尝试映射竞争性测试,成为竞争性测试(存在于我在mongo中的文档中)
注意:此模型由NHibernate共享(因此是虚拟的)
我在文件里看不到任何明显的东西
我该怎么做?这就成功了:
BsonClassMap.RegisterClassMap<Competitor>(cm =>
{
cm.AutoMap();
cm.MapField("_competitorBests").SetElementName("CompetitorBests");
});
BsonClassMap.RegisterClassMap(cm=>
{
cm.AutoMap();
cm.MapField(“_competitorBests”).SetElementName(“competitorBests”);
});
遇到了相同的问题!谢谢您是否能够在.CompetitorBests属性上运行linq查询?对我来说它爆炸了。