Why not

If(....)
  condition = Restrictions.Eq("Prop", ...);

If(...)
  condition = other..

If(..)
  Query.Add(....Or(..., condition));

Sory for the ... But im on the phone

2011/3/10, Craig van Nieuwkerk <[email protected]>:
> I am trying to write a query along the lines of this pseudo code with
> nHibernate.
>
> ICriteria query = repo.QueryAlias("a");
>
> var condition = // this is the problem, need a detached condition
>
> if (options.Option1) {
>     condition.Add(Restrictions.Eq("Prop", 1));
> }
>
> if (options.Option2) {
>     condition.Add(Restrictions.Eq("Prop", 1));
> }
>
> if (options.Option3) {
>     query.Add(
>         Restrictions.Or(
>             Restrictions.Eq("Prop2, 1),
>             condition
>         )
>     )
> } else {
>     query.Add(condition);
> }
>
> Is it possible to write something like this?
>
> Craig
>
> --
> 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.
>
>

-- 
Enviado desde mi dispositivo móvil

-- 
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