Is there any clever shorthand in C# to this:
list.Where(x=> x.a.b == null || x.a.b == desiredIntValue)
Is there any clever shorthand in C# to this:
list.Where(x=> x.a.b == null || x.a.b == desiredIntValue)
Copyright © 2021 Jogjafile Inc.
In later C# versions you can use pattern matching with logical patterns, specifically
orin this case (assuming list isIEnumerable<>since the newer language features usually are not supported by expression trees) and constants:For non-constant values you can do something like:
Or for nullable value types
But not sure if it can be considered as shorthand.