NHibernate: how to do lookup a specific date in Nhibernate
Posted
by Daoming Yang
on Stack Overflow
See other posts from Stack Overflow
or by Daoming Yang
Published on 2010-04-03T10:36:21Z
Indexed on
2010/04/03
11:03 UTC
Read the original article
Hit count: 230
nhibernate
How I can lookup a specific date in Nhibernate?
I'm currently using this to lookup one day's order.
ICriteria criteria = SessionManager.CurrentSession.CreateCriteria(typeof(Order))
.Add(Expression.Between("DateCreated", date.Date.AddDays(-1), date.Date.AddDays(1)))
.AddOrder(NHibernate.Criterion.Order.Desc("OrderID"));
I tried the following code, but they did bring the data for me.
Expression.Eq("DateCreated", date)
Expression.Like("DateCreated", date)
Note:
The pass in date value will be like this 2010-04-03 00:00:00
,
The actual date value in the database will be like this 2010-03-13 11:17:16.000
Can anyone let me know how to do this?
Many thanks.
© Stack Overflow or respective owner