且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决此异常“在类中找不到属性'ProductCode'的设置器..."

更新时间:2022-05-09 07:06:01

解决方案

如果要使用NHibernate执行SQL,请验证SQL中列的别名.名称应与您的类中的属性完全相同.

Solution

If you are executing the SQL with NHibernate, verify the Alias Name of the column in your sql. The name should be exactly as name the property in your class.

例如错误:

select Product_Id as "ProductCode " 
from Products

请参见别名中的空格.这可能是导致您出错的原因.

See the white space in alias name. This can be cause of your error.

检查SQL中所有列的别名.