2012-07-19 51 views
0

我的LINQ2SQL查询有问题。我试图得到只有TabA行关联TabCName列包含例如lorem。有任何想法吗 ?Linq2Sql嵌套表

我尝试

(from x in db.TabA 
x.TabB.FirstOrDefault(y => y.TabC.name == "lorem") != null 
x).ToList(); 

但我得到method is not supported error

enter image description here

+0

表的默认值是什么? – 2012-07-19 11:26:19

+0

试着看看这个问题:http://stackoverflow.com/questions/2170141/error-method-not-supported-by-linq-to-entities – 2012-07-19 11:26:48

回答

0

这里的解决方案

(from x in db.TabA 
where x.TabB.Count(a => a.TabC.name == "lorem") > 0 
select x).ToList(); 
0

你也可以试试这个 它的工作就像 '类似' SQL查询。

(from x in db.TabA 
where x.TabB.Count(a => a.TabC.name.contains("lorem")) > 0 
select x).ToList();