在Nhibernate中将hbm.xml映射转换为Confirmist代码映射
本文关键字:映射 转换 Confirmist 代码 xml Nhibernate 中将 hbm | 更新日期: 2023-09-27 18:30:01
目前我正在将hbm.xml文件转换为代码映射(Confirmist)。我可以转换所有内容,但我不知道如何转换manyToMany属性中的where子句。
<set inverse="true" name="Skills" table="UserPrivileges" mutable="true">
<key>
<column name="UserID" />
</key>
<many-to-many class="School.Campaign.Domain.Skill, School.Campaign.Domain" where="PrivilegeType = 'Skill'">
<column name="PrivilegeID" />
</many-to-many>
</set>
当我像这样转换时:
Set(x => x.Skills, m =>
{
m.Schema("dbo");
m.Table("UserPrivileges");
m.Key(k => k.Column("UserID"));
m.Cascade(Cascade.None);
}, col => col.ManyToMany(m =>
{
m.Columns(x => x.Name("PrivilegeID"));
})
);
但是,由于缺少where子句和类类型,这将不起作用。有谁能帮帮我吗。
您应该能够在.ManyToMany
映射选项中调用.Where
:
Set(x => x.Skills, m =>
{
m.Schema("dbo");
m.Table("UserPrivileges");
m.Key(k => k.Column("UserID"));
m.Cascade(Cascade.None);
}, col => col.ManyToMany(m =>
{
m.Columns(x => x.Name("PrivilegeID"));
m.Where("PrivilegeType = 'Skill'"); // <-----
}));