-2

正如标题所描述的。我被卡住了,在 LINQ 语句中简单地使用 and、xor 或表达式。

from s in db.Items
where <Other boolean operations> &&
      s.Category.Contains("something") &&
      s.IsReviewed == false

我希望其他布尔操作在哪里过滤列表,并且其余项目不应属于“某物”类别,除非 IsReviewed 布尔为假。

另一种表达方式是:我希望显示任何类别的项目,除了“某物”类别,除非它没有经过审查。

感谢您的指导。

4

3 回答 3

1

根据我理解的所有评论,您正在寻找所有不在的项目Category.Contains("something")或如果它们在的项目!IsReviewed

from s in db.Items
where <Other boolean operations> &&
      (!s.Category.Contains("something") || !s.IsReviewed)

您可以移动否定,这样您就可以排除任何存在Category.Contains("something")和存在的项目IsReviewed

from s in db.Items
where <Other boolean operations> &&
      !(s.Category.Contains("something") && s.IsReviewed)
于 2016-12-30T22:04:45.267 回答
0

根据您的评论更新答案以反映逻辑。

from s in db.Items
where <Other boolean operations> &&
      (!s.Category.Contains("something") || s.IsReviewed == false)
于 2016-12-30T21:06:55.133 回答
-1

因此,您想要类别不是“某物”或IsReviewed为假的所有项目。

于 2016-12-30T21:07:08.897 回答