错误:LINQ to Entities 无法识别方法“System.String Aggregate[String,String](System.Collections.Generic.IEnumerable 1[System.String], System.String, System.Func
3[System.String,System.String,System.String])”方法,并且此方法不能被翻译成商店表达式。
Linq 表达式:
Items = context.TESTANSWER.Where(x => x.ID == 6729223232)
.Join(context.QUESTIONREPOs, x => x.QUESTIONID, y => y.ID, (x, y) => new { x = x, y = y })
.Join(context.OPTIONREPOs, p => p.x.QUESTIONID, q => q.QUESTIONID, (p, q) => new { p = p, q = q }).Where(p => p.p.x.RESPONSEID == p.q.ID)
.GroupJoin(context.TESTANSWERASSOCIATION, c => c.p.x.ID, b => b.TESTANSWERID, (c, b) => new { c = c, b = b })
.SelectMany(
n => n.b.DefaultIfEmpty(),
(n, b) =>
new QuestListItemObj
{
State = n.c.p.x.STATE,
Association = n.b.Select(l => l.ASSOCIATION.TITLE).ToList().Aggregate((s, t) => s + ", " + t),
Description = n.c.p.y.DESCRIPTION,
Question = n.c.p.y.QUESTION,
Answer = n.c.q.OPTIONTEXT,
}).ToList();
我也刚刚尝试过 SelectMany 但得到了同样的错误..
Affiliaiton = n.b.SelectMany(l => l.AFFILIATION.TITLE).Aggregate(string.Empty, (s, t) => s + ", " + t),