might be related:
http://groups.google.com/group/nhibernate-development/browse_thread/thread/51913633e6ab0ddc/d23b7889897c5d0c

On Dec 20, 4:27 am, Dan Lash <[email protected]> wrote:
> I'm having the exact same problem as you. To get past your current
> problem I think you need to call visitor.Visit(condition) before
> AsBooleanExpression(). But from there I think you'll run into other
> problems like me.
>
> I've tried to take the loop out of the equation - also I couldn't get
> treeBuilder.False() to work so I went with Equality 1=0:
>
> var column = visitor.Visit(arguments[0]).AsExpression();
>
> treeBuilder.BooleanOr(
>      treeBuilder.BooleanOr(
>          treeBuilder.Equality(
>              treeBuilder.Constant(0),
>              treeBuilder.Constant(1))
>          , treeBuilder.Like(
>              column,
>              treeBuilder.Constant("hi").AsExpression()))
>      , treeBuilder.Like(
>              column,
>              treeBuilder.Constant("bye").AsExpression()));
>
> So basically it's trying to build an expression that looks like this:
>
> ((0 = 1) OR (column LIKE 'hi') OR (column LIKE 'bye'))
>
>                OR
>               /    \
>          OR      column LIKE 'bye'
>        /      \
> 0 = 1       column LIKE 'hi'
>
> Returning just one BooleanOr from BuildHql works correctly, but
> nesting another BooleanOr produces this at runtime:
>
> Exception of type 'Antlr.Runtime.NoViableAltException' was thrown.
> [.Where(NHibernate.Linq.NhQueryable`1[Event], Quote((evt, ) =>
> (.IsLike(evt.Description, p1, ))), )]
>
> Any ideas on how to build up multiple OR statements in a custom
> HqlGenerator?
>
> Thanks!
>
> Dan Lash
>
> On Dec 19, 10:24 am, Nikodem Rafalski <[email protected]>
> wrote:
>
>
>
>
>
> > Hi, I'm extending NHibernate Linq provider to support my custom
> > predicates in Where clause. But I've got one problem. I cant' join two
> > or more HqlExpression with boolean or operator.
>
> > Here is my code (only important lines provided)
>
> > HqlExpression resultNode = treeBuilder.False();
> > foreach ()
> > {
> >      HqlExpression condition = treeBuilder.Like(leftExpression,
> > rigthExpression);
> >      resultNode =
> > treeBuilder.BooleanOr(resultNode.AsBooleanExpression(),
> > condition.AsBooleanExpression());
>
> > }
>
> > return resultNode;
>
> > The problem is that AsBooleanException throws that it cannot cast
> > HqlExpression to HqlBooleanExpression. How should it be done.

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