Is it possible to extend NHibernate to add support for aggregate functions that is unique to a database system? I have a handful of queries that use the array_agg() function (and others) in PostgreSQL that I’d like to convert to HQL/ICriteria.
Thanks!
Yes. It’s possible.
Take a look:
http://ayende.com/Blog/archive/2006/10/01/UsingSQLFunctionsInNHibernate.aspx
You could do something like this:
Then you can use
myfunctionin your HQL statements. You just need to register the Dialect in your NH Configuration.Edit:
Good news, this should work for Criteria queries as well.
This is code (from Reflector) in PostgreSQLDialect
So in you ICriteria, you could do:
All this should work because you’re extending a NH Dialect.
HTH