Nhibernate:2 列总和的限制

发布于 2024-10-03 21:12:19 字数 141 浏览 0 评论 0原文

我可以使用 HNibernate Criteria 创建此 sql 查询吗:

Select * from Table1 where Column1 > (Column2 + Column3)

所有 3 列都是 int32。 谢谢

Can I create this sql query using HNibernate Criteria:

Select * from Table1 where Column1 > (Column2 + Column3)

All 3 columns are int32.
Thanks

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

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

发布评论

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

评论(2

天暗了我发光 2024-10-10 21:12:20

您可以使用 Expression 并编写一些 SQL,这对我有用。

criteria.Add(Expression.Sql("Column1 > (Column2 + Column3)"));

You can use an Expression and write some SQL, that's what works for me.

criteria.Add(Expression.Sql("Column1 > (Column2 + Column3)"));
过期以后 2024-10-10 21:12:19

好吧,在第 n 次阅读了这个问题的问题后,我决定编写一个不包括编写 SQL 的实现。

您可以在 http://savale.blogspot.com/2011 查看实施情况/04/nhibernate-and-missing.html 你可以用它来写:

criteria.Add(
   Restrictions
     .GeProperty("Prop1",
                 new ArithmeticOperatorProjection("+",
                                 NHibernateUtil.Int32,
                                 Projections.Property("Prop2"), Projections.Property("Prop3")
                                                  )
                )
);

Well, after reading for the n-th time a question with this exact problem i decided to write an implementation that doesn't include writing SQL.

You can check the implementation at http://savale.blogspot.com/2011/04/nhibernate-and-missing.html with which you can write:

criteria.Add(
   Restrictions
     .GeProperty("Prop1",
                 new ArithmeticOperatorProjection("+",
                                 NHibernateUtil.Int32,
                                 Projections.Property("Prop2"), Projections.Property("Prop3")
                                                  )
                )
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文