Given:
WHERE (@Id Is NULL OR @Id = Table.Id)
If @Id is null: expression evaluates to true. The second part @Id = Table.Id is still being considered? or enough that the expression is evaluated as true, given that the first part (which is the case in C #).
This is true because of some of the more complex OR statements, where it is important to know if all the details are evaluated.
UPDATE:
Since then I have found this syntax to be a good alternative.
WHERE (Table.Id = ISNULL(@Id, Table.Id))
source share