我目前正致力于其中一个项目,我需要将xml映射转换为代码映射。
我有一个带有多对多的ISET集合以及where子句。我已经完成了代码映射,但是将where子句放在代码映射中的哪个位置?
<set inverse="true" name="SystemRoles" table="UserPriv" mutable="true">
<cache usage="read-write" />
<key>
<column name="UserID" />
</key>
<many-to-many
class="SampleProject.Domain.SystemRole, SampleProject.Domain"
where="PrivilegeType = 'SystemRole'">
<column name="PrivilegeID" />
</many-to-many>
</set>
我的代码映射:
Set(x => x.SystemRoles, m =>
{
m.Schema("dbo");
m.Table("UserPriv");
m.Inverse(true);
m.Key(k => k.Column("UserId"));
m.Cascade(Cascade.None);
}, col => col.ManyToMany(p =>
{
p.Column(x => x.Name("PrivilegeId"));
})
);
我应该放在哪里:where="PrivilegeType = 'SystemRole'"
答案 0 :(得分:0)
其中应属于many-to-many
xml
映射
Set(x => x.SystemRoles, m =>
{
// set mapping
},
col => col.ManyToMany(p =>
{
// mapping of the many-to-many
p.Column(x => x.Name("PrivilegeId"));
p.Where("PrivilegeType = 'SystemRole'");
})
);
但不完全确定,如果代码映射已经支持所有功能......
更多&#34;文档&#34; Adam Bar http://notherdev.blogspot.com/2012/01/mapping-by-code-onetomany-and-other.html
EXTEND,查看https://github.com/nhibernate/nhibernate-core/blob/master/releasenotes.txt
- [NH-2997] - 缺少多对多关系的Where()子句(描述中的解决方案)