My question is quite simple but still, I'm searching over 2 hours to find the solution.
In c# I have a where clause: where ?hospitalID
and then I am binding this value (hospitalID) with my condition:
cmd.Parameters.AddWithValue("?hospitalID", (filters.hospitalID != 0) ? "operation.hospitalID=" + filters.hospitalID : "true");
So what I am saying here is: if the variable filters.hospitalID is not zero, go ahead and create a condition (where operation.hospitalID=filters.hospitalID
). Otherwise "nullify" the condition (where true
).
If I change manually the string where operation.hospitalID=2
it works. But with the AddWithValue method, it simply doesn't work.