views:

27

answers:

2

Hello I want to generate a sql query with ICriteria interface like that

select * from tableName where (dataColumn like '%2010-06-09%')

I researched in google and I found CONVERT() function to do this:

SELECT * FROM DATE_SAMPLE WHERE CONVERT(CHAR(10),SAMPLE_DATE,120) = '2003-04-09'

How can I do this in NHibernate wtih ICriteria?

A: 

In general, you should keep dates (and times and datetimes) in a suitable datatype (e.g. DateTime) rather than treating them as string. Can you not just pass a DateTime into ICriteria?

Damien_The_Unbeliever
A: 

You might be able to create your own criteria using. Check out the following:

http://xlib.wordpress.com/2009/12/04/integrating-freetext-search-in-nhibernate-detached-criteria/

Trent