[英]The LINQ lambda expression not working
I have the below Linq expression 我有下面的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();
I am getting below error in concat
我在
concat
遇到错误
The LINQ expression node type 'Lambda' is not supported in LINQ to Entities.
What went wrong in my code? 我的代码出了什么问题?
Instead of 代替
queue = queue.OrderBy(f => orderByLambda);
Use: 采用:
queue = queue.OrderBy(orderByLambda);
Two notes on your code: 关于代码的两个注意事项:
Contains
, etc. Contains
等。 nullCheckExpression
and parameterExpression
are. nullCheckExpression
和parameterExpression
是。 In general, this is not how you would sort LINQ to Entities anyway - it should be something like queue.OrderBy(f => fx).ThenBy(f => fy);
queue.OrderBy(f => fx).ThenBy(f => fy);
- you have to define which fields from your select are actually used for the sort.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.