How to solve this exception "Could not find the installer for the" ProductCode "property in the class ..."

I get the following exception:

"Could not find a setter for property 'ProductCode'in class ...OrderItem.class " 

The property (ProductCode) is one of my table keys.

See how property declarations are in the class.

 public class OrderItem : EntityBase { public virtual short Company { get; set; } public virtual int Order { get; set; } public virtual string Seri { get; set; } public virtual string ProductCode { get; set; } public virtual string Crop { get; set; } . . . } 

below this my display.

 public MapOrderItem() { Table("IPED"); CompositeId() .KeyProperty(c => c.Company, "C_EMP") .KeyProperty(c => c.Order, "P_PED") .KeyProperty(c => c.Seri, "S_PED") .KeyProperty(c => c.ProductCode, "C_PSV"); Map(c => c.C_CFO).Not.Nullable(); Map(c => c.AnotherCurrency).Column("V_IPE"); . . . } 

I checked doubts similar to mine, but solutions do not solve my problem. already tried matching with

 (c => c.ProductCode).Access.ReadOnly(); (c => c.ProductCode).Access.Field(); (c => c.ProductCode).ReadOnly(); 

to run a query directly in the database does not show me any error, only the correct data.

+6
source share
1 answer

Decision

If you are running SQL with NHibernate, check the column alias name in your sql. The name must be exactly the same as the name of the property in your class.


eg. wrong:

 select Product_Id as "ProductCode " from Products 

See the space in the alias. This may be the cause of your error.

Check the alias name for all columns in your sql.

+5
source

Source: https://habr.com/ru/post/985705/


All Articles