Suppose I have classes Foo
and Bar
as follow:
public class Foo
{
public string F1 {set; get;}
public string F2 {set; get;}
public Bar ContainerBar {set; get;}
}
public class Bar
{
public string B1 {set; get;}
public string B2 {set; get;}
public List<Foo> Foos {set; get;}
}
Following linq query has errors saying that foo
does not contain a property named F1
.
var query = from foo in session.Linq<Foo>()
select foo.ContainerBar;
query = query.Where(foo => foo.F1 == "abcdef");
I know foo
in second statement is really a Bar
because query selects ContainerBar
.
The question is know how can I add a dynamic where clause to query without changing origianl query? Final goal is to have sub-queries with linq-to-nhibernate.