I have a property that should be read-only, I performed mapping via code and assign the parameter to read-only, however, it gives me an exception stating that the property setter was not found
Exit: "Could not find a setter for property 'IndexValue 'in class ... "
My IndexValue attribute, which is where the exception occurs is as follows in the class.
public class MyClass: EntityBase
{
.
.
.
public virtual decimal CropCode{ get; set ; }
public virtual decimal UnityDiscount { get; set; }
public virtual decimal IndexValue { get; set; }
}
I also tried to remove the virtual one and did not succeed.
My mapping was done as follows:
public MapMyClass()
{
Table("MyTable");
CompositeId()
.KeyProperty(c => c.Code, "CODI_EMP")
.KeyProperty(c => c.OrCode, "PEDI_PED")
Map(c => c.CropCode).Column("CODI_CUL");
Map(c => c.UnityDiscount).Column("DSAC_IPE");
.
.
Map(c => c.IndexValue).ReadOnly();
}
I've tried to do the mapping also changing to:
Map(c => c.IndexValue).Access.ReadOnly();
and also with
Map(c => c.IndexValue).Access.Field();
The error occurs when nhibernate tries to execute the query, I already executed the query directly in the database and everything happens normal.