假设我有课程Foo
,Bar
如下所示:
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;}
}
以下 linq 查询有错误说不foo
包含名为F1
.
var query = from foo in session.Linq<Foo>()
select foo.ContainerBar;
query = query.Where(foo => foo.F1 == "abcdef");
我知道foo
第二条语句确实是Bar
因为查询选择ContainerBar
。
问题是知道如何在不更改原始查询的情况下添加动态 where 子句进行查询?最终目标是使用 linq-to-nhibernate 进行子查询。