【发布时间】:2013-07-21 16:29:24
【问题描述】:
关于the answer proposed in this post,谁能解释一下为什么LINQPad不会为此生成任何SQL?
var query = Products.Select(p => new
{
Orders = p.Orders.OrderByWithDirection(x => x.PurchaseDate, true)
});
例外情况如下:
NotSupportedException:方法 'System.Linq.IOrderedEnumerable
1[LINQPad.User.Order] OrderByWithDirection[Phase,String](System.Collections.Generic.IEnumerable1[LINQPad.User.Order], System.Func`2[LINQPad.User.Order,System.String], Boolean)' 没有支持的翻译到 SQL。
【问题讨论】:
-
那么错误是什么?如果我们不知道发生了什么,我们真的无能为力。
-
可能是因为延迟执行?如果您发出
var results = query.ToList(),是否会生成任何 SQL? -
@JonSkeet: 异常如下: NotSupportedException: Method 'System.Linq.IOrderedEnumerable
1[LINQPad.User.Order] OrderByWithDirection[Phase,String](System.Collections.Generic.IEnumerable1[LINQPad.User.Order], System.Func`2[LINQPad.User.Order, System.String], Boolean)' 不支持 SQL 转换。 -
@Douglas:不会生成 SQL。