我有以下Linq表达式
var orderByLambda = Expression.Lambda<Func<Queue, int>>(
nullCheckExpression, parameterExpression);
queue = context.Table
.Join(context.tablea, cq => cq.a, r => r.a, (cq, r) => new { cq, r })
.Join(context.tableb, s => s.r.b, se => se.b, (s, se) => new { s, se })
.Join(context.tablec, u => u.s.cq.c, us => us.c, (u, us) => new { u, us })
.Where(cq => cq.u.s.cq.c == Utilities.Authentication.c)
.Where(cq => buildStatusOrder.Contains((BuildStatusEnum)cq.u.s.cq.d))
.OrderBy(o => o.u.se.b)
.Select(s => new QueueInfo
{
x = s.u.c,
y = s.u.d,
z = s.u.a
});
queue = queue.OrderBy(f => orderByLambda);
var concat = queue.GroupBy(e => new { e.x, e.y, e.z })
.OrderBy(v => v.FirstOrDefault().segmentID)
.ToList()
.Select(ss => new QueueInfo
{
x = ss.x,
y = ss.y,
z = ss.z,
})
.AsQueryable();
我在concat
The LINQ expression node type 'Lambda' is not supported in LINQ to Entities.
我的代码出了什么问题?
答案 0 :(得分:3)
而不是
queue = queue.OrderBy(f => orderByLambda);
使用:
queue = queue.OrderBy(orderByLambda);
答案 1 :(得分:0)
关于代码的两点说明:
Contains
等。nullCheckExpression
和{ {1}}。一般来说,这不是你如何对LINQ to Entities进行排序 - 它应该类似parameterExpression
- 你必须定义select中哪些字段实际用于排序。 (见第1点)