And*_*uiz 8 c# nhibernate fluent-nhibernate
我收到以下异常:
"Could not find a setter for property 'ProductCode'in class ...OrderItem.class "
Run Code Online (Sandbox Code Playgroud)
属性(ProductCode)是我的表键之一.
看看课堂上的财产申报是怎样的.
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; }
.
.
.
}
Run Code Online (Sandbox Code Playgroud)
在我的映射下面.
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");
.
.
.
}
Run Code Online (Sandbox Code Playgroud)
检查了类似于我的疑虑,但解决方案并没有解决我的问题.已经尝试使用执行映射
(c => c.ProductCode).Access.ReadOnly();
(c => c.ProductCode).Access.Field();
(c => c.ProductCode).ReadOnly();
Run Code Online (Sandbox Code Playgroud)
直接在数据库中运行查询,不会显示任何错误,只显示正确的数据.
如果使用NHibernate执行SQL,请验证sql中列的别名.名称应该与您班级中的属性完全一样.
例如不正确:
select Product_Id as "ProductCode "
from Products
Run Code Online (Sandbox Code Playgroud)
请参阅别名中的空白区域.这可能是您的错误的原因.
检查sql中所有列的别名.
| 归档时间: |
|
| 查看次数: |
5672 次 |
| 最近记录: |