Let's say I have a mongo document that looks like this:
{
"name": "John Doe"
}
Now let's say my model looks like this:
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Is it possible to map one property from the document to two properties in the model?
I tried a ClassMap like this:
BsonClassMap.RegisterClassMap<Person>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.FirstName).SetElementName("name").SetSerializer(new FirstNameSerializer());
cm.MapMember(c => c.LastName).SetElementName("name").SetSerializer(new LastNameSerializer());
}
But I got an error:
"The property 'LastName' of type 'Person' cannot use element name because it is already being used by property 'FirstName'."
Is there a way to allow this with ClassMap?