【发布时间】:2010-01-14 04:21:55
【问题描述】:
我正在玩弄表达式树和各种 Linq 语法。我写了以下内容:
using (NorthwindDataContext DB = new NorthwindDataContext())
{
DataLoadOptions dlo = new DataLoadOptions();
// Version 1
dlo.AssociateWith<Customer>(c => c.Orders.Where(o => o.OrderID < 10700).Select(o => o));
// Version 2
dlo.AssociateWith<Customer>(c => from o in c.Orders
where o.OrderID < 10700
select o);
}
版本 1 方法返回一个错误,提示“子查询不支持运算符 'Select'。”
虽然第 2 版运行良好。据我了解,我正在写完全相同的东西,但一个是“点”符号语法,另一个是查询表达式语法。
我在这里遗漏了什么吗?为什么一个错误而不是另一个“如果”它们实际上是同一个查询?
【问题讨论】:
标签: c# linq linq-to-sql