How to map a read-only property in Fluent nhibernate, error in identifying setter

3

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.

    
asked by anonymous 20.04.2015 / 22:04

1 answer

2

Check your search can, be that you have any table that has the incorrect value, all forms of mapping that you tried to use are correct.

In Oracle you need to be careful to put the reference name of the columns the same. It may be that a space will give you this whole problem. In the error that you listed the name of your 'IndexValue' is with space at the end, if your column does not have that space, that may be the cause of the problem.

    
23.04.2015 / 15:18