-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: CreateCriteria and MONTH
PostPosted: Mon Jan 12, 2009 11:25 am 
Newbie

Joined: Thu Jul 03, 2008 11:16 am
Posts: 7
Hallo!

Is it possible to use MONTH in a CreateCriteria-statement?

Does NHibernate support YEAR and/or MONTH?

I have a sql-statement like
select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11)

Best Regards from

Mats


Top
 Profile  
 
 Post subject: CreateCriteria and MONTH, solution
PostPosted: Tue Jan 13, 2009 10:28 am 
Newbie

Joined: Thu Jul 03, 2008 11:16 am
Posts: 7
Hello again!

I tried this and it works fine for me:

ICriteria crit = CurrentSession.CreateCriteria(typeof(Obs), "obs") .Add(Expression.Sql("MONTH({alias}.ObsDatum)=?", 11, NHibernateUtil.Int32));

IList<Obs> list = crit.List<Obs>();

// Mats


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.