-->
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: OrExpression?
PostPosted: Fri Jul 10, 2009 1:56 pm 
Newbie

Joined: Fri May 01, 2009 12:51 pm
Posts: 3
Something really simple to do in SQL, but for some reason I cannot figure out how to do it in NHibernate.

Code:
select * from cars where (car_id = 3) or (share = 1)


Here's what my code looks like without the OR

Code:
Cars[] ct = Cars.FindAll(
   new ICriterion[] {
      Expression.Eq("CarId", id)
   }
);


So...

I'd like to add the OR in there. I was thinking it was like this:

Code:
Cars[] ct = Cars.FindAll(
   new ICriterion[] {
      Expression.Eq("CarId", id),
      OrExpression.Equals("Share", true)
   }
);


That gives me this error:
Cannot implicitly convert type 'bool' to 'NHibernate.Expression.ICriterion'

Any help is appreciated!


Top
 Profile  
 
 Post subject: Re: OrExpression?
PostPosted: Sun Jul 12, 2009 1:31 pm 
Newbie

Joined: Fri May 01, 2009 12:51 pm
Posts: 3
I figured it out. Here's the answer for future reference:

Code:
Expression.Or(Expression.Eq("CarId", id),Expression.Eq("Share", true))


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.