Cast null values
I have a query in my TableAdapter that returns a decimal type, but can have also return a null value.
How can I assing a 0 if it returns a null value?
My actual code is:
decimal idUsuario; idUsuario = (decimal)queriesTableAdapter.GetIdUsuarioByUsuario(Usuario) |
and it fails if a null value is returned.
I have test this code and it works:
if (queriesTableAdapter.GetIdUsuarioByUsuario(Usuario) == DBNull.Value) idUsuario = 0M; else idUsuario = (decimal)queriesTableAdapter.GetIdUsuarioByUsuario(Usuario); |
but I'm lokking for a better method because this execute the query 2 times.

