我正试图在LinqPad中运行以下查询,第10行不断出现上述错误。
From c in Courses Where c.CourseID = 212
From cc in c.CourseContents Where cc.Active And Not cc.Deleted Order By cc.OrderIndex
Group cc by c Into Content = Group
Select New With {
c,
.Content = From cc in Content Select New With {
.id = cc.CourseContentID,
.content = If(cc.ContentTypeID = 1,
from a in Assessments Where a.AssessmentID = cc.ContentID select a,
If (cc.ContentTypeID = 2, from cf in CourseFiles Where cf.CourseFileID = cc.ContentID select cf,
from ct in CourseTexts Where ct.CourseTextID = cc.ContentID select ct))
}
}
我尝试添加select foo=cf,但没有帮助。
如何修复此查询?
我刚刚遇到这个问题,想看看SO上是否有任何悬而未决的问题需要这个答案。
问题所在:
If (cc.ContentTypeID = 2, from cf in CourseFiles Where cf.CourseFileID = cc.ContentID select cf,
现在的情况是最后一个逗号不明确。可以选择多个项目,比如select x, y, z, ...
,这样最后一个逗号就可以这样解释,需要另一个标识符。要解决此问题,请在整个From。。。选择语句。
像这样:
If (cc.ContentTypeID = 2, (from cf in CourseFiles Where cf.CourseFileID = cc.ContentID select cf),