我试图允许用户通过querystring参数动态更改查询。我无法让小组在vb.net工作。我想要返回每个组的ID,名称和计数。
' load all of the types
Dim baseQuery = db.Answers _
.Where(Function(a) a.Question.CorrectAnswer <> a.answer) _
.Where(Function(a) a.Question.TypeId = TypeId)
If catId <> 0 Then
baseQuery = baseQuery _
.Where(Function(x) x.Question.CategoryId = catId) _
.ToList()
End If
If approachId <> 0 Then
baseQuery = baseQuery _
.Where(Function(x) x.ApproachId = approachId) _
.ToList()
End If
Dim grouppedQuestionTypesincorrectTotal = baseQuery _
.GroupBy(Function(x) x.Question.TypeId) _
.Select(Function(x) New With {.id = x.id}) _
.ToList()
Dim grouppedCategorieincorrectTotal = baseQuery _
.GroupBy(Function(x) x.Question.CategoryId) _
.ToList()
Dim grouppedApproachesincorrectTotal = baseQuery _
.GroupBy(Function(x) x.ApproachId) _
.ToList()
ViewBag.QuestionTypes = grouppedQuestionTypesincorrectTotal
ViewBag.Categories = grouppedCategorieincorrectTotal
ViewBag.Approaches = grouppedApproachesincorrectTotal