Use Expression.AndAlso, not Expression.And.
RP
On Tuesday, September 4, 2012 9:33:34 PM UTC+1, Christian I. wrote:
>
> Hello,
>
> I have this error :
> {"Unable to cast object of type 'NHibernate.Hql.Ast.HqlBitwiseAnd' to type
> 'NHibernate.Hql.Ast.HqlBooleanExpression'."}
>
> I create a predicate in C# with Expression Method, like this :
> var listExpression = new List<Expression>();
> var parameter = Expression.Parameter(typeof(T));
>
> listExpression.Add(
> Expression.Call(
> ((MemberExpression)memberExpression), "Contains", null,
> Expression.Constant((string)MyValue))
> );
>
> Expression body = Expression.Constant(true);
> foreach (var expression in listExpression)
> body = Expression.And(body, expression);
>
> The predicate looks like : see attachment.
>
> I use this predicate like this :
> session.QueryOver<Customer>().Where(prediate).List()
>
> That's work when I have one condition in my predicate but I get the error
> when I have more than one
>
> Any idea ?
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/DgMyXwkKdDIJ.
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.