I’m new user in StackOverflow, and I need a help in a HQL string..
In SQL my query is something like this..
SELECT DISTINCT DATEPART(yyyy, Moment) AS Year,
FROM PRODUCT_SOURCE
How can I convert this to HQL?
I’ve tried this, but didn’t work..
query = "SELECT DISTINCT DATEPART(year, p.Moment) as Year, " +
"FROM Product_Source as p";
I am basing this on SQL2008 dialect so change as you see fit.
And to use you would use your HQL like this
Edit As Diego quite righly points out most of the functions in MSSQL server are already registered. For a full list see https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/MsSql2000Dialect.cs
So just use:-