将 XML 映射转换为多对多 ISET 的代码映射
Convert XML mappings to Code Mapping for ISET of ManyToMany
我目前正在处理其中一个项目,我需要将 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'"
应属于 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'");
})
);
但不完全确定,如果代码映射中已经支持所有功能...
更多 "documentation" http://notherdev.blogspot.com/2012/01/mapping-by-code-onetomany-and-other.html 作者:Adam Bar
EXTEND,勾选 https://github.com/nhibernate/nhibernate-core/blob/master/releasenotes.txt
- [NH-2997] - Where() clause with many-to-many relation is missing (solution in description)
我目前正在处理其中一个项目,我需要将 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'"
应属于 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'");
})
);
但不完全确定,如果代码映射中已经支持所有功能...
更多 "documentation" http://notherdev.blogspot.com/2012/01/mapping-by-code-onetomany-and-other.html 作者:Adam Bar
EXTEND,勾选 https://github.com/nhibernate/nhibernate-core/blob/master/releasenotes.txt
- [NH-2997] - Where() clause with many-to-many relation is missing (solution in description)