Why does IQueryable.All() return true on an empty collection?

后端 未结 11 1759
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 04:46

So I ran into a situation today where some production code was failing precisely because a method performed exactly as documented in MSDN. Shame on me for not reading the d

11条回答
  •  情话喂你
    2020-12-01 05:40

    I think it makes sense. In logic, the complement of FOR ALL is NOT (THERE EXIST). FOR ALL is like All(). THERE EXIST is like Any().

    So IQueryable.All() is equivalent to !IQueryable.Any(). If your IQueryable is empty, then both returns true based on MSDN doc.

提交回复
热议问题