Hi @gal mor , Welcome to Q&A.
For checking null values you should use a ternary method similar to the following.
int columnValue = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
For the code you write:
public static string SafeGetString(this OracleDataReader reader, int colIndex)
{
if (!reader.IsDBNull(colIndex))
return reader.GetString(colIndex);
return string.Empty;
}
You could call it like this.
string columnValue = reader.SafeGetInt32(0);
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.