Add common dialect functions as extension methods for QueryOver

Description

Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.

Extensions methods can be added for these to allow queries along the lines of:

s.QueryOver<Person>()
.Where(p => p.BirthDate.Year() == 1970)
.List()

... which can be translated to:

.Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))

... and in turn to:

datepart(year, this_.BirthDate) = @p0;

Environment

None

Attachments

2

Activity

Show:
Fabio Maulo
July 30, 2011 at 2:11 PM

Closed after final release of NH3.2.0GA

Vahid Nasiri
May 22, 2011 at 7:52 AM

OK. Thank you.
Yes, I saw that when I created the patch. everything in the diff file was red because of that tabbing style!

Richard Brown
May 22, 2011 at 6:29 AM

Committed. Thanks. Just a reminder, for any future patches, that the NH code uses hard-tabs.

Richard Brown
May 22, 2011 at 3:22 AM

Thanks vahid. The new patch looks good. And I like renaming the Year() extension to YearPart() (makes it clearer it's an NH customisation).

Cheers.

Vahid Nasiri
May 17, 2011 at 9:17 AM

A new patch has been attached.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created May 1, 2011 at 3:42 AM
Updated July 30, 2011 at 2:11 PM
Resolved June 4, 2011 at 12:20 PM
Who's Looking?