queryOver = Session.QueryOver<Actor>()
                   .Where(x => x.Number.IsLike(number + "%"))
                   .And(x => x.IdNumber.IsLike(idNumber + "%"))
                   .WithSubquery
                   .WhereProperty(x => x.Id)
                   .In(detachedAddressQueryOver)
                   .WithSubquery
                   .WhereProperty(x => x.Id)
                   .In(detachedDerivedActorQueryOver);

This will return you *IEnumerable *or *IQuerable* object and then you can
put your check after this.

if(countryCodeId != 0)
queryOverList = queryOver.Where(x => x.CountryCode.Id ==
countryCodeId).ToList();
else
queryOverList = queryOver.ToList();


Thanks
avi
+(0)7795-147-740






On Tue, Jul 5, 2011 at 3:12 PM, Richard Brown (gmail) <
[email protected]> wrote:

>   so if i do not pass any value, it would be 0.
>>
>
> So don't pass it 0?  (Or don't add that restriction if the codeId is 0?)
>
> -----Original Message----- From: james
> Sent: Tuesday, July 05, 2011 2:02 PM
> To: nhusers
> Subject: [nhusers] Nihibenate - queryover with int
>
>
> I have a problem with the following,
>
> queryOverList = Session.QueryOver<Actor>()
>                   .Where(x => x.Number.IsLike(number + "%"))
>                   .And(x => x.Country.Id == countryCodeId)
>                   .And(x => x.IdNumber.IsLike(idNumber + "%"))
>                   .WithSubquery
>                   .WhereProperty(x => x.Id)
>                   .In(detachedAddressQueryOver)
>                   .WithSubquery
>                   .WhereProperty(x => x.Id)
>                   .In(**detachedDerivedActorQueryOver)
>                   .List();
>
>
> my countryCodeId is an integer.
>
> so if i do not pass any value, it would be 0. So when nothing is
> passed in I want to return all for that countryCode condition since I
> am not passing in any value. Buit instead it searched for 0 and return
> me nothing. What can do with such int's
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to nhusers+unsubscribe@**
> googlegroups.com <nhusers%[email protected]>.
> For more options, visit this group at http://groups.google.com/**
> group/nhusers?hl=en <http://groups.google.com/group/nhusers?hl=en>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to nhusers+unsubscribe@**
> googlegroups.com <nhusers%[email protected]>.
> For more options, visit this group at http://groups.google.com/**
> group/nhusers?hl=en <http://groups.google.com/group/nhusers?hl=en>.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to