There is a modified version of the PredicateBuilder that works fine with NH3. It has a little override to the ExpressionBuilder that renames the lambda parameter and rebuilds the expression tree.
It can be found there: http://www.primordialcode.com/Blog/Post/nhibernate-linq-dynamic-filtering-lambda-expressions I did encouter a problem with that solution when nested lambdas are in place and there is no need to rename the parameter of the nested lambda. I changed the code slightly to overcome this scenario: protected override Expression VisitParameter(ParameterExpression p) { if (p.Type == _newParam.Type) return _newParam; else return p; } On Jan 10, 5:07 pm, James Crowley <[email protected]> wrote: > In case anyone else comes across this and are looking for a short-term fix, > I just ended up just chaining several "Where" expressions together instead > - so > > var item = something.Where(t=>t.xx) > if (condition) > item = item.Where(t=>t.yy) > > and so on. > > On 7 January 2011 11:46, José F. Romaniello <[email protected]> wrote: > > > > > > > > > I think that for an strange reason, Expr.Invoike in one side doesn't break. > > I've tests on that here: > > >http://linqspecs.codeplex.com/SourceControl/changeset/view/f8b3326482... > > <http://linqspecs.codeplex.com/SourceControl/changeset/view/f8b3326482...> > >http://linqspecs.codeplex.com/SourceControl/changeset/view/f8b3326482... > > > <http://linqspecs.codeplex.com/SourceControl/changeset/view/f8b3326482...>But > > yes, i think you are right, ant it should works calling invoke on both > > sides. > > > 2011/1/7 Fabian Schmied <[email protected]> > > >> I'm not sure if the workaround you've posted will always work: you're > > >> still using Expression.Invoke in those cases where the parameters are > >> not the same for both expressions. I believe that those cases would > >> still cause the exception described by the original poster > > > -- > > 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]<nhusers%[email protected] > > > > > . > > For more options, visit this group at > >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.
