Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NHCD-35 - SQL Functions day, year, month not working in JetDialect #6

Open
nhibernate-bot opened this issue May 19, 2017 · 0 comments

Comments

@nhibernate-bot
Copy link

Thomas Kalmar created issue - 22/Jul/09 12:00 PM

the JetDialect has some strange ways to try to extract the year(month, day) part of an datetime:

crit.Add(Restrictions.Eq(Projections.SqlFunction("Year", NHibernateUtil.DateTime, Projections.Property("lastChanged")), filter.LastChanged.Year));

adds some "and (extract year from ?)" to the sql. This does not work in M$ Access.
To fix this add

RegisterFunction("year", new SQLFunctionTemplate(NHibernateUtil.DateTime, "year(?1)"));
RegisterFunction("month", new SQLFunctionTemplate(NHibernateUtil.DateTime, "month(?1)"));
RegisterFunction("day", new SQLFunctionTemplate(NHibernateUtil.DateTime, "day(?1)"));

to the JetDialect
After that all worked like a charm


Thomas Kalmar added a comment - 17/Sep/09 10:13 PM

Silly me. Should be:

RegisterFunction("year", new SQLFunctionTemplate(NHibernateUtil.Int32, "year(?1)"));
RegisterFunction("month", new SQLFunctionTemplate(NHibernateUtil.Int32, "month(?1)"));
RegisterFunction("day", new SQLFunctionTemplate(NHibernateUtil.Int32, "day(?1)"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant