tags:

views:

103

answers:

1

Please do not redirect me towards the other similar kinds of HQL in Stackoverflow, because they did not work for me. I really appreciate your direction on it. Thanks.

Reproducing this kind of query in Nhibernate with ICriteria API :

 SELECT DISTINCT FileName From CustomerFile WHERE name = ' ' AND timeframe = ''
+1  A: 

Why not just use the custom SQL that you've sketched in, above, and map the result column to Strings? Why jump through ORM hoops to do something simple?

session
 .CreateSQLQuery("SELECT DISTINCT FileName From CustomerFile WHERE name = ' ' AND timeframe = ''")
 .AddScalar("FILENAME", NHibernateUtil.String)
Jonathan Feinberg
Thanks, project's entire Dat aaccess logic is done with NHibernate, so I dont want to deviate it from it. Of course doing this with SQL server is really trivial task.
Shiva
To get compile time integrity perhaps?
ssg
It *is* still "done with NHibernate"! See https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html_single/#d0e8963
Jonathan Feinberg
Thanks Jonathan for the hyperlink.
Shiva
+1 for that hyperlink
Shiva