For mapping classes I have this.
public sealed class MyMap : ClassMap<MyBase>
{
public MyMap()
{
Map(m => m.EventDate).Index(1);
Map(m => Math.Round(m.Price,2)).Index(2);
}
}
Is there a way that will work as this errors out when rounding. I know you can use custom converters but that seems like over kill just to truncate input to two decimal places.
CodePudding user response:
Something like this?
public sealed class MyMap : ClassMap<MyBase>
{
public MyMap()
{
Map(m => m.EventDate).Index(1);
Map(m => m.Price).Index(2).Convert(row => Math.Round(row.Row.GetField<decimal>("Price"),2));
}
}