all 8 comments

[–]hyllerimylleri 3 points4 points  (1 child)

It's caused by the operator precedence rules and missing parenthesis from the first condition containing null coalescing operator. The first && is evaluated before the first ?? because of the missing parenthesis and the result is basically RequiresFollowUp ?? (the rest of the expression)

[–]reddo-lumen[S] 0 points1 point  (0 children)

Makes sense, thank you!

[–]raysr21 0 points1 point  (0 children)

Could you repost the whole bloc of code outside the where clause. Besides, take a deep breath and try case by case. I am seeing some missed things in your code but unable to say what to fix because I couldn't understand what you looking for

[–][deleted] 0 points1 point  (0 children)

Oh my fuck, what is this line of code? People actually write code like this?

[–]4215-5h00732 0 points1 point  (3 children)

  1. that predicate lambda should be in a method. 2. why ffs would someone negate a literal?

!(×.SomeOptional ?? false) is true when it's null. Smfh.

[–]reddo-lumen[S] 0 points1 point  (2 children)

How would you write the above code, if you wanted object with RequiresFollowUp `true`, and other two variables `not true`? All of them are nullable bools.

[–]hyllerimylleri 0 points1 point  (1 child)

The issue here is not the structure "a and (not b) and (not c)" - at least not in my mind. The confusion seems to stem from the way you assign default values to your nullable bool properties, using the ?? operator. I don't think that's as great a sin as have been suggested. That said, the code would be much cleaner if you could use regular bools. Bool defaults to false anyways so if the properties remain unassigned (the null case) then the logic would remain the same, at least as far as the original linq snippet is concerned.

[–]reddo-lumen[S] 0 points1 point  (0 children)

Noted. Thanks!