public static SqlInt32 ConvertToSqlInt32(object value)
{
if (value == DBNull.Value)
{
return(SqlInt32.Null);
}
Type type = value.GetType();
switch (DataStorage.GetStorageType(type))
{
case StorageType.Byte:
return((SqlInt32)((byte)value));
case StorageType.Int16:
return((SqlInt32)((short)value));
case StorageType.UInt16:
return((SqlInt32)((ushort)value));
case StorageType.Int32:
return((int)value);
case StorageType.SqlByte:
return((SqlByte)value);
case StorageType.SqlInt16:
return((SqlInt16)value);
case StorageType.SqlInt32:
return((SqlInt32)value);
}
throw ExceptionBuilder.ConvertFailed(type, typeof(SqlInt32));
}