courses = courses.Where(
c => queryParameters.ShowInActive || c.Flags.Contains((ulong)CourseFlags.Active)
&&
(queryParameters.AuthorId <= 0 ||
(c.Authors != null && c.Authors.Exists(a => a.ID == queryParameters.AuthorId)))
&&
(queryParameters.CategoryIDs == null || queryParameters.CategoryIDs.Count == 0 ||
(c.Tags != null && c.Tags.Any(t => queryParameters.CategoryIDs.Contains(t.ID)))
&&
queryParameters.CourseIDs == null || queryParameters.CourseIDs.Count == 0 ||
queryParameters.CourseIDs.Contains(c.ID))
).ToList();
问题是queryParameters.CourseIDS.Count()
返回 157 但上面的 lambda 表达式返回 2500 条记录。我究竟做错了什么?
我还确保ShowInactive
设置为 true 并且CategoryIDs
为 null 并且AuthorId
为 0