Fluent nhibernate Fluent NHibernate HasManyToMany()IDictionary复合ID问题
我使用的是Fluent NHibernate 1.1.1.694,它使用的语法与FNH1.0稍有不同,尤其是在字典映射方面 在我的模型中,我有员工、地址和地址类型邮政、实物等Fluent nhibernate Fluent NHibernate HasManyToMany()IDictionary复合ID问题,fluent-nhibernate,many-to-many,idictionary,composite-id,Fluent Nhibernate,Many To Many,Idictionary,Composite Id,我使用的是Fluent NHibernate 1.1.1.694,它使用的语法与FNH1.0稍有不同,尤其是在字典映射方面 在我的模型中,我有员工、地址和地址类型邮政、实物等 public class Employee { // <snip other properties /> public virtual IDictionary Addresses { get; set; } public Employee() { this.Ad
public class Employee
{
// <snip other properties />
public virtual IDictionary Addresses { get; set; }
public Employee()
{
this.Addresses = new Dictionary();
}
}
public enum AddressType
{
Physical,
Postal
}
public class Address
{
public virtual int Id { get; private set; }
public virtual IList Lines { get; set; }
public virtual string City { get; set; }
public virtual string Zip { get; set; }
}
我的映射:
生成以下.hbm.xml代码段:
<map inverse="true" name="Addresses" table="EmployeeAddresses" mutable="true">
<key>
<column name="Employee_id" />
</key>
<index type="Domain.Entities.AddressType, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Key" />
</index>
<many-to-many class="Domain.Entities.Address, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Address_id" />
</many-to-many>
</map>
我要生成的.hbm.xml是
<map inverse="true" name="Addresses" table="EmployeeAddresses" mutable="true">
<key>
<column name="IdentityType" />
<column name="IdentityValue" />
</key>
<index type="Domain.Entities.AddressType, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Key" />
</index>
<many-to-many class="Domain.Entities.Address, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Address_id" />
</many-to-many>
</map>
显然这将失败,因为我没有告诉它有一个复合ID用于父键。但是我找不到方法来告诉你。.HasManyToMany的.Columns和.ParentKeyColumns不存在
我应该如何绘制这张地图
<map inverse="true" name="Addresses" table="EmployeeAddresses" mutable="true">
<key>
<column name="IdentityType" />
<column name="IdentityValue" />
</key>
<index type="Domain.Entities.AddressType, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Key" />
</index>
<many-to-many class="Domain.Entities.Address, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="Address_id" />
</many-to-many>
</map>