Nhibernate:限制为2列之和 [英] Nhibernate: restriction with sum of 2 columns
本文介绍了Nhibernate:限制为2列之和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用HNibernate条件创建此sql查询吗?
Can I create this sql query using HNibernate Criteria:
从Table1中选择*,其中Column1>(Column2 + Column3)
Select * from Table1 where Column1 > (Column2 + Column3)
所有3列均为int32. 谢谢
All 3 columns are int32. Thanks
推荐答案
好吧,在第n次阅读了有关此确切问题的问题后,我决定编写一个不包括编写SQL的实现.
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.
您可以在 http://savale.blogspot上查看实施情况. com/2011/04/nhibernate-and-missing.html ,您可以使用它来编写:
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")
)
)
);
这篇关于Nhibernate:限制为2列之和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文