flutter / nhibernate 映射问题
嘿伙计们,我非常感谢以下方面的帮助。我们使用 Fluent 来控制 nhibernate 的映射,到目前为止一切进展顺利。我们基本上已经有了一个基于计划的 CMS 系统,但我在使用 HasMany 映射排除非活动子类别时遇到了问题。
因此,我们有以下稍微简化的数据表,映射到合理的 BO。
[类别] ID 姓名 父ID Schedule_Id
[时间表] ID 已暂停(位 0/1) 开始日期 StopDate
CategoryMap 看起来有点像这样(vb.net 抱歉!)。
Public Sub New()
Id(Function(x) x.Id)
Map(Function(x) x.Name)
HasMany(Function(x) x.Children).Inverse().KeyColumn("Parent_id").Cascade.All()
References(Function(x) x.Parent)
References(Function(x) x.Schedule).ForeignKey("Schedule_id").Fetch.Join().Nullable()
End Sub
我想做的是在 HasMany 映射上添加一个过滤器,但似乎无法根据我的需要找到工作地点。
有人可以指出我正确的方向吗?
非常感谢,
迈克。
Hey Guys I would very much appreciate some help with the following. We're using fluent to control the mappings for nhibernate and its all gone well so far. We've basically got a scheduled based CMS system and I'm having problems using the HasMany mapping to exclude the non-live child categories.
So we have the following Data Tables, simplified slightly which map to sensible BO's.
[Category]
Id
Name
Parent_Id
Schedule_Id
[Schedule]
Id
IsPaused (Bit 0/1)
StartDate
StopDate
The CategoryMap looks a bit like this (vb.net sorry!).
Public Sub New()
Id(Function(x) x.Id)
Map(Function(x) x.Name)
HasMany(Function(x) x.Children).Inverse().KeyColumn("Parent_id").Cascade.All()
References(Function(x) x.Parent)
References(Function(x) x.Schedule).ForeignKey("Schedule_id").Fetch.Join().Nullable()
End Sub
What I would like to do is add a filter on the HasMany mapping, but can't seem to get Where to work as I need to.
Could someone please point me in the right direction?
Many Thanks,
Mike.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有显示子类,所以我不确定过滤器可能是什么。假设您想要过滤 IsActive 位列,映射将是:
关键点是Where 子句包含 SQL 片段而不是 HQL,因此您必须使用数据库字段名称而不是属性名称。
You don't show the child class so I'm not sure what the filter might be. Assuming you want to filter on an IsActive bit column the mapping would be:
The key point is that the Where clause contains a snippet of SQL not HQL, so you have to use database field names instead of property names.