I'm working with an older Oracle database, and I feel there's likely a better way to go about unboxing the values I retrieve from the database.
Currently, I have a static class full of different type-specific methods:
public static int? Int(object o)
{
try
{
return (int?)Convert.ToInt32(o);
}
catch (Exception)
{
return null;
}
}
..and so on for different types, but I feel there should be a better way? If I want to unbox a value, I do something along the lines of...
int i;
i = nvl.Int(dataRow["column"]); //In this instance, "column" is of a numeric database type
I thought about using a generic class to handle all the different types, but I couldn't really figure out the best way to go about that.
Any ideas?