我有这个非常简单的课程
public class ProductAttributeValuePortal
{
public virtual int ID { get; set; }
public virtual Domain.Entity.Portals.ProductPortal Product { get; set; }
public virtual Attribute Attribute { get; set; }
public virtual string Value { get; set; }
}
使用这个非常简单的地图
public ProductAttributeValueMap ()
{
Table("DM.dbo.ProductAttributeValues");
Id(x => x.ID, "ProductAttributeValue_id");
References(x => x.Product);
References(x => x.Attribute);
Map(x => x.Value);
}
每次进行插入时,NHibernate都会选择属性,如:
NHibernate: INSERT INTO MachineData.dbo.ProductAttributeValues (Value, Product_id,
Attribute_id) VALUES (@p0, @p1, @p2); select SCOPE_IDENTITY();@p0 = '6745', @p1 = 39, @p2 = 'BSTD'
NHibernate: SELECT attribute_.Attribute_id, attribute_.Name as Name21_, attribute_.AttributeType as Attribut3_21_, attribute_.TagName as TagName21_, attribute_.MapTo as MapTo21_ FROM MachineShared.dbo.Attributes attribute_ WHERE attribute_.Attribute_id=@p0;@p0 = 'DLB'
我做错了什么。我在哪里可以找到一些关于nhibernate / Fluent nhibernate的最新书?
答案 0 :(得分:0)
如何分配ID?如果它是标识,则NHibernate必须返回DB才能获得ID字段。