I'm trying to get a private backing field mapped in MongoDB.
My model looks like:
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(); }
}
}
I'm basically trying to map _competitorBests, to be CompetitorBests (which exists in my document in mongo)
Note: This model is shared by NHibernate (hence the virtual
)
I can't see anything obvious in the docs.
How do I do it?
This did the trick:
BsonClassMap.RegisterClassMap<Competitor>(cm =>
{
cm.AutoMap();
cm.MapField("_competitorBests").SetElementName("CompetitorBests");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With