开发者

How to use the formula property in NHibernate mapping

I have a question regarding how to use the formula property to be used in the SQL where clause. Sepcifically, I'd like to use (datepart(hh, getdate())) as the formula and the res开发者_Python百科ulting SQL that I expect is

Select select_list from table_name where (datepart(hh, getdate())) < 17

But I kept the where clause like this:

where (this_0_.hh, getdate())) <= 17

I am not sure why the alias is inserted before the "hh" date part.

Any help on how to get this where clause right is highly appreciated!

Thanks.


The alias is inserted because the parser doesn't know hh is a literal (if MS had used a string, you wouldn't have this problem, as you'd be able to use 'hh' without a problem)

The easiest workaround is creating a function (call it gethour) that returns datepart(hh, getdate()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜