我可以附加 HasMany 实体的条件吗?

发布于 2024-09-10 00:31:58 字数 223 浏览 1 评论 0原文

我有一个事件类,它使用位置类的 HasMany 属性。所有工作都使用静态 Find 方法。但我需要向 Location 表添加一个 where 子句。我可以使用Where 属性,但在获取结果时我并不总是需要该子句。

在查询事件时是否可以使用 DetachedCriteria 或类似的方法来过滤位置表?我可以使用 hql,但似乎我必须手动创建联接,如果我使用 HasMany 属性,这似乎是多余的。

I have an Incident class that uses the HasMany attribute to a Location class. All works using the static Find methods. But I need to add a where clause to the Location table. I can use the Where attribute but I don't always want that clause when fetching results.

Is there any way to maybe use DetachedCriteria or something similar while querying for Incident to filter the Location table? I could use hql but it seems that I have to create my joins manually which seems redundant if I use the HasMany attribute.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奶气 2024-09-17 00:31:58

[HasMany] 属性有一个 Where 属性来过滤关系。

进行半全局过滤的另一种方法是使用 会话过滤器

The [HasMany] attribute has a Where property that filters the relationship.

Another way to do semi-global filtering is with session filters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文