从 nhibernate QueryOver 返回 TSubType
我正在尝试使用 nhibernate 中的 QueryOver 从父集合中选择子集合。 这就是我在 HQL 中尝试做的事情:
SELECT as_kitten FROM Cat as_Cat
JOIN as_Cat.Kittens as_kitten
这如何转换为 QueryOver 甚至使用 JoinAlias?
IList<Kitten> kittens = session.QueryOver<Cat>()
.JoinQueryOver<Kitten>(c => c.Kittens)
.Select(??)
.List()
到目前为止我能找到的最接近的东西是 NHibernate QueryOver
干杯
编辑 假设这是一种单向关系,即。小猫不知道猫的事
I am trying to select the children from a parent collection using QueryOver in nhibernate.
This is what I am trying to do in HQL:
SELECT as_kitten FROM Cat as_Cat
JOIN as_Cat.Kittens as_kitten
How does this translate to QueryOver or even using JoinAlias?
IList<Kitten> kittens = session.QueryOver<Cat>()
.JoinQueryOver<Kitten>(c => c.Kittens)
.Select(??)
.List()
The closest thing I could find so far is NHibernate QueryOver
Cheers
EDIT
Assuming this is a one way relationship, ie. kittens dont' know about cat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的例子看起来相当微不足道。如果您已经拥有父级并将集合映射为猫实体内的一对多,那么如果您是延迟加载,那么您所要做的就是访问该集合。
如果你只有父级的 id,你可以轻松地执行类似的操作,甚至不需要连接:
Your example seems rather trivial. If you already have the parent and have the collection mapped as a one to many inside your cat entity then all you would have to do if you were lazy loading is access the collection.
If you only have the id of the parent you could easily do something like this without even needing a join: