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: 330
        
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_onis mapped to a property of typeDateTime.lifespanis mapped to a property of typeTimeSpan.sysdateis 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