nhibernate - how to user year() and month() functions in NH Criteria API? -


I have to use the year () and month () function in the Criterion API to be able to express commercial filter . Expression like

  cri.Add (expression .g ("year (by date date)", year. Value)); Cri.Add (expression. ("Year (period date)", year. Value));  

Obviously, do not work - is there a solution to get it?

I know that this is entirely possible in HQL, but I am getting the criteria API because some additional processes are being processed by sorting, paging, etc.


Sample HCl solution that I would like to overwrite Criteria API:

  Var ym = year * 100 + months; Var hql = ... (: between 100 * year (f.Duration.DateFrom) + month (f.Duration.DateFrom) and 100 * year (f.Duration.DateTo) + month (f.Duration.DateTo) " It is possible to achieve this by using the projections.SQL function. Work Solution:  


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -