Basic date/time manipulation in NHiberate query

Posted by Yann Trevin on Stack Overflow See other posts from Stack Overflow or by Yann Trevin
Published on 2010-05-27T18:54:08Z Indexed on 2010/06/12 17:13 UTC
Read the original article Hit count: 286

Filed under:
|
|
|
|

I'm trying to restrict my NHibernate query with some basic date/time manipulation. More specifically, I want to execute the following statement (pseudo-SQL):

select * from article where created_on + lifespan >= sysdate

with:

  • created_on is mapped to a property of type DateTime.
  • lifespan is mapped to a property of type TimeSpan.
  • sysdate is the current date/time (of the database server or ofthe application host, I don't care)

Is there any built-in way to do that by using the Criteria-API or HQL?

return session
  .CreateCriteria<Article>()
  .Add( ? )
  .List<Article>();

© Stack Overflow or respective owner

Related posts about c#

Related posts about nhibernate