I have the following class:
public class ReturnDto
{
[Column("PARC_NUM")]
public int ParcelNumber { get; set; }
~[Column("CUSTOM_TAXE")] or [Column("AUTOMATIC_TAXE")]~
public decimal Taxe { get; set; }
}
I'm working in this Api using Dapper/Dommel and that class is supposed to be filled with the values from the data base. The problems is that it doesn't work for the second property (the "Taxe" one) because, as follows, the Query have two possible columns to take the value from:
...
ag.PARC_NUM AS ,
case when pp.IDT_MODALID = 3 then ag.CUSTOM_TAXE else ag.AUTOMATIC_TAXE end AS Taxe,
...
I tried setting the column name as Taxe (because that's how I name it, after all), but it just doesn't get mapped correctly. Actually, it just throws an exception poiting that such thing doesn't exist.
I am missing some standard setting or it just can't be done that way?
Try assign one of the valid column name
case when pp.IDT_MODALID = 3
then ag.CUSTOM_TAXE
else ag.AUTOMATIC_TAXE
end AS AUTOMATIC_TAXE ,
or add a field in the class
public class ReturnDto
{
[Column("PARC_NUM")]
public int ParcelNumber { get; set; }
~[Column("CUSTOM_TAXE")] or [Column("AUTOMATIC_TAXE")]~
public decimal Taxe { get; set; }
[Column("TAXE")]
public decimal Taxe { get; set; }
}