I've just started using FluentMap and I'm looking to map the same column to 2 properties, as they need the same value. Here's my map:
internal class DefaultsMap : EntityMap<Defaults>
{
internal DefaultsMap()
{
Map(d => d.HistoricalValues.Cost).ToColumn("defaultValue");
Map(d => d.FutureValues.Cost).ToColumn("defaultValue");
//other mappings...
}
}
This throws the following error:
Exception: Duplicate mapping detected. Property 'Cost' is already mapped to column 'Cost'.
So it looks like I can't map the same column to 2 different properties, or is this because the properties themselves are called the same thing (Cost)?
As per Amit Joshi's answer it doesn't look like this is possible in it's current form as the mapper must have distinct naming. Unfortunately, I'm not able to rename the column for just one of them as the query is returning all values from a generic table to create a list of Defaults objects.
As a workaround, in this case I've been able to achieve what I wanted by assigning to the property for one of them and to the 'Value' property of the 'Cost' property for the other like this:
Map(d => d.HistoricalValues.Cost).ToColumn("defaultValue");
Map(d => d.FutureValues.Cost.Value).ToColumn("defaultValue");