internal static string GetCSType(DbHType type, bool nullable) { switch (type) { case DbHType.String: case DbHType.StringUnlimited: return "string"; case DbHType.Binary: return "byte[]"; case DbHType.Date: case DbHType.DateTime: return nullable ? "DateTime?" : "DateTime"; case DbHType.Decimal: return nullable ? "decimal?" : "decimal"; case DbHType.Int16: return nullable ? "short?" : "short"; case DbHType.Int32: return nullable ? "int?" : "int"; case DbHType.Int64: return nullable ? "long?" : "long"; case DbHType.Double: return nullable ? "double?" : "double"; case DbHType.Complex: return "object"; default: throw new Exception("Errore type " + type); } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="type"></param> public DbHParameter(string name, object value, DbHType type) { ParameterName = name; if(type == DbHType.Complex) throw new Exception("Parametri con tipo di dati Complex non supportati."); DbHType = type; Value = value; CheckForDataString(); CheckForFloatString(); }
internal static string GetConvertFunc(DbHType type) { switch (type) { case DbHType.Date: case DbHType.DateTime: return "ToDateTime"; case DbHType.Int64: return "ToInt64"; case DbHType.Int32: return "ToInt32"; case DbHType.Int16: return "ToInt16"; case DbHType.StringUnlimited: case DbHType.String: return "ToString"; case DbHType.Double: return "ToDouble"; default: throw new Exception("Errore type " + type); } }
private OracleDbType GetOracleType(DbHType dbhType) { // Source: http://docs.oracle.com/html/B14164_01/featOraCommand.htm#g1025242 switch (dbhType) { #region Oracle-specific Type Mapping case DbHType.Binary: return OracleDbType.Blob; case DbHType.Boolean: return OracleDbType.Byte; case DbHType.Currency: return OracleDbType.Decimal; case DbHType.Date: case DbHType.DateTime: case DbHType.Time: return OracleDbType.Date; case DbHType.TimeStamp: return OracleDbType.TimeStamp; case DbHType.Decimal: return OracleDbType.Decimal; case DbHType.Float: return OracleDbType.Single; case DbHType.Double: return OracleDbType.Double; case DbHType.Guid: return OracleDbType.Varchar2; case DbHType.Int32: return OracleDbType.Int32; case DbHType.Int64: return OracleDbType.Int64; case DbHType.String: return OracleDbType.Varchar2; case DbHType.Xml: return OracleDbType.XmlType; case DbHType.StringUnlimited: return OracleDbType.Clob; default: throw new Exception("Data Type not supported by this Oracle Database implementation"); #endregion } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="type"></param> /// <param name="direction"></param> /// <param name="size"></param> public DbHParameter(string name, object value, DbHType type, ParameterDirection direction, int size) : this(name, value, type) { Direction = direction; Size = size; }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="type"></param> /// <param name="direction"></param> public DbHParameter(string name, object value, DbHType type, ParameterDirection direction) : this(name, value, type) { Direction = direction; }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="type"></param> /// <param name="size"></param> public DbHParameter(string name, object value, DbHType type, int size) : this(name, value, type) { Size = size; }