The proposed patch to make all data layers almost safe proof compatable in future.
It's for MS SQL data layer, but the only difference is in the DBAccess.cs file and class CoolCoverter.
For MySQL it reads for any data layer like this^
public static class CoolConverter
{
public static int VerifyInt32(object value)
{
if (value == DBNull.Value) return 0;
return Convert.ToInt32(value);
}
public static bool VeryfyBool(object value)
{
if (value == DBNull.Value || value.ToString() == "0") return false;
if ( value.ToString() == "1") return true;
return Convert.ToBoolean(value);
}
}
For postgreSQL it's like this
public static class CoolConverter
{
public static int VerifyInt32(object o)
{
//if (o == DBNull.Value || o =="f" ) o = 0;
// if (o == "t") o = 1;
return Convert.ToInt32(o);
}
public static bool VeryfyBool(object o)
{
if (o.ToString() == "t") { return true; }
if (o.ToString() == "f") { return false; }
return false;
}
}
For MS SQL Server it's simply
public static class CoolConverter
+ {
+ public static int VerifyInt32(object o)
+ {
+ return (int)o;
+ }
+ public static bool VeryfyBool(object o)
+ {
+ return (bool)o;
+ }
+ }
In the last case it's much more faster than using Convert.ToInt32 or Convert.ToBool :wink:
Edited by user
13 years ago
|
Reason: Not specified