?? Coalesce for empty string?

Something I find myself doing more and more is checking a string for empty (as in “” or null) and a conditional operator. A current example: s.SiteNumber.IsNullOrEmpty() ? “No Number” : s.SiteNumber; This is just an extension method, it’s equivalent to: string.IsNullOrEmpty(s.SiteNumber) ? “No Number” : s.SiteNumber; Since it’s empty and not null, ?? won’t … Read more

Best way to check for “empty or null value”

What is best way to check if value is null or empty string in Postgres sql statements? Value can be long expression so it is preferable that it is written only once in check. Currently I’m using: coalesce( trim(stringexpression),”)=” But it looks a bit ugly. stringexpression may be char(n) column or expression containing char(n) columns … Read more