I have two classes:
class Foo
{
string Name
}
class Bar
{
IList<Foo> Foos;
}
And the following expression tree:
var fooFilters = (Expression<Func<Foo, bool>>)(foo => foo.Name == "baz");
In NHibernate I can write:
Session.Query<Bar>().Where(bar => bar.Foos.Any(foo => foo.Name == "baz"));
And it works.
Although, I can't write:
Session.Query<Bar>().Where(bar => bar.Foos.Any(fooFilters));
It's a compilation error, as IEnumerable.Any
does not expect an Expression<TDelegate>
.
Is it possible to achieve? Do I have to rewrite the fooFilters Expression, or is there another way?
I have very little knowledge in expression tree manipulation, can anyone point me to the right direction?
I'm using framework 3.5, for that matters.