Here's a method to convert C# types to the most common OracleDbTypes
private static OracleDbType GetOracleDbType(object o)
{
if (o is string) return OracleDbType.Varchar2;
if (o is DateTime) return OracleDbType.Date;
if (o is Int64) return OracleDbType.Int64;
if (o is Int32) return OracleDbType.Int32;
if (o is Int16) return OracleDbType.Int16;
if (o is sbyte) return OracleDbType.Byte;
if (o is byte) return OracleDbType.Int16; -- <== unverified
if (o is decimal) return OracleDbType.Decimal;
if (o is float) return OracleDbType.Single;
if (o is double) return OracleDbType.Double;
if (o is byte[]) return OracleDbType.Blob;
return OracleDbType.Varchar2;
}
Also, for very large character data values, you may want to use OracleDbType.Clob
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…