I was looking to find a simple way to map a class property to a table column and I found Dapper fluent map which I thought was going to be a great alternative to the considerable boilerplate code that one would need to write simply to map a property to a column. But it does not seem to work.
FluentMapper.Initialize(c =>
{
c.AddMap(new MarginSummaryMap());
});
[Serializable]
[Table("PbCash")]
public class MarginSummary : Entity
{
public long RunId { get; set; }
public DateTime? BusinessDate { get; set; }
[Write(false)]
public DateTime ProcessDate { get; set; }
public string Broker { get; set; }
public string BrokerAccountId { get; set; }
public string Account { get; set; }
public string Folio { get; set; }
public decimal? ActualExcessOrDeficit { get; set; }
[Write(false)]
public decimal? ProjectedExcessOrDeficit { get; set; }
public string Comment { get; set; }
}
public class MarginSummaryMap : EntityMap<MarginSummary>
{
public MarginSummaryMap()
{
Map(c => c.ActualExcessOrDeficit).ToColumn("ExcessOrDeficit");
}
}
Then when I am trying to save data I get an exception that the column ActualExcessOrDeficit
does not exist in the table. Well it does not and the mapping is supposed to convert to the actual column ExcessOrDeficit
.
Looks like this is a bug in Dapper.FluentMap
since the problem goes way if I change type from decimal?
to decimal
.
Did anyone have this working - I would love to know how to fix this.