HasManyToMany 关系上的 PropertyRef
有没有办法使用 FluentNhibernate 在多对多关系上指定 PropertyRef
?
我有3张桌子
- 事件(id,...)
- EventOnline(id, eventId, onlineId)
- 在线(id、代码、...)
在 EventOnline 表上,我通过其“code”列而不是 Id 连接到 Online 表。如果这是常规的一对一关系,我会执行类似
References(x => x.Online, "onlineId").PropertyRef("Code");
EventOnlineMap 中的操作。
但我想在 EventMapping 中将其表示为多对多关系。
HasManyToMany(x => x.Onlines).Table("EventOnline").ParentKeyColumn("EventId").ChildKeyColumn("OnlineId").LazyLoad().AsSet().Access.ReadOnlyPropertyThroughLowerCaseField(Prefix.Underscore);
问题是我无法在 HasManyToMany 构造上指定 PropertyRef("code")
。如果我要在 xml 中进行映射,则该属性确实存在。
<set name="Onlines" table="EventOnline" access="nosetter.camelcase-underscore" schema="EventsCalendar.dbo" lazy="true">
<key column="eventId"></key>
<many-to-many class="CommonLookupService.Data.Domain.Online, CommonLookupService.Data" column="onlineId" property-ref="Code"></many-to-many>
</set>
所以问题是...... FluentNhibernate 中 HasManyToMany 构造上的 PropertyRef 等价物是什么?
Is there a way to specify a PropertyRef
on a many to many relationship using FluentNhibernate?
I have 3 tables
- Event(id, ...)
- EventOnline(id, eventId, onlineId)
- Online(id, code, ...)
On the EventOnline table I connect to the Online table via its "code" column instead of Id. If this was a regular one-to-one relationship I would do something like
References(x => x.Online, "onlineId").PropertyRef("Code");
in the EventOnlineMap.
But I want to represent this as a many-to-many relationship in in the EventMapping.
HasManyToMany(x => x.Onlines).Table("EventOnline").ParentKeyColumn("EventId").ChildKeyColumn("OnlineId").LazyLoad().AsSet().Access.ReadOnlyPropertyThroughLowerCaseField(Prefix.Underscore);
The problem is I can't specify PropertyRef("code")
on the HasManyToMany construct. This attribute does exist if I was to do the mapping in xml.
<set name="Onlines" table="EventOnline" access="nosetter.camelcase-underscore" schema="EventsCalendar.dbo" lazy="true">
<key column="eventId"></key>
<many-to-many class="CommonLookupService.Data.Domain.Online, CommonLookupService.Data" column="onlineId" property-ref="Code"></many-to-many>
</set>
So the question is.... What is the equivalent of PropertyRef on a HasManyToMany construct in FluentNhibernate?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HasManyToMany().ChildPropertyRef().PropertyRef()
是在针对 NH 2.1 编译的 FNH 1.1 中实现的HasManyToMany().ChildPropertyRef().PropertyRef()
is implemented in FNH 1.1 which is compiled against NH 2.1