假设我有类Foo
和Bar
如下:动态LINQ到NHibernate的查询问题
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
。
问题是我知道如何在不改变origianl查询的情况下添加一个动态where子句来进行查询?最终目标是使用linq-to-nhibernate进行子查询。现在
但where子句必须在运行时添加。 – 2010-11-10 05:07:06
我已经更新了我的答案 – mathieu 2010-11-10 08:04:57