0
我在使用属性关系映射多对多时遇到了问题。就像这里的问题具有属性的多对多映射 - 主键是外键
fluent nhibernate - Many to Many mapping with attribute
但是我没有在我的中产阶级的一个主键,取而代之的则是由其他两个班的ID的。
报价SKU类(中产阶级)
public class QuotationSKUCost : Entity
{
public virtual decimal UnitPrice { get; set; }
public virtual Quotation Quotation { get; set; }
public virtual QuotationRequestSKU QuotationRequestSKU { get; set; }
}
报价类
public class Quotation : Entity
{
public virtual int Id { get; set; }
public virtual DateTime ValidUntil { get; set; }
public virtual string Data { get; set; }
public virtual ICollection<QuotationSKUCost> QuotationSKUCosts { get; set; }
}
报价请求SKU
public class QuotationRequestSKU : Entity
{
public virtual int Id { get; set; }
public virtual int Quantity { get; set; }
public virtual ICollection<QuotationSKUCost> QuotationSKUCost { get; set; }
}
中产阶级映射!!
public QuotationSKUCostMapping()
{
Table("QuotationSKUCost");
CompositeId() //need to map QuotationId and QuotationRequestSKUid as Composite key
.KeyProperty(x => x.Quotation, "QuotationId")
.KeyReference(x => x.QuotationRequestSKU, "QuotationRequestSKUId");
Map(x => x.UnitPrice);
}
尝试调试时,我得到的错误是:
无法确定类型:ORM.Entities.Quote.Quotation,ORM, 版本= 1.0.0.0,文化=中性公钥=空,为列: NHibernate.Mapping.Column(QuotationId)
编辑:添加报价马pping
public QuotationMapping()
{
Id(x => x.Id).Column("QuotationId");
Map(x => x.ValidUntil);
Map(x => x.Data);
HasMany(x => x.QuotationSKUCosts).KeyColumn("QuotationId");
}
什么是你的'Quotation'类的配置? – Guillaume
我已经添加了引用映射 – Steve