public SybaseParameter(string parameterName, SybaseType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value) { metaParameter = new TdsMetaParameter(parameterName, size, isNullable, precision, scale, value); SybaseType = dbType; Direction = direction; SourceColumn = sourceColumn; SourceVersion = sourceVersion; }
public SybaseParameter Add(string parameterName, SybaseType sybaseType, int size, string sourceColumn) { return(Add(new SybaseParameter(parameterName, sybaseType, size, sourceColumn))); }
public SybaseParameter Add(string parameterName, SybaseType sybaseType, int size) { return(Add(new SybaseParameter(parameterName, sybaseType, size))); }
public SybaseParameter (string parameterName, SybaseType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value) { metaParameter = new TdsMetaParameter (parameterName, size, isNullable, precision, scale, value); SybaseType = dbType; Direction = direction; SourceColumn = sourceColumn; SourceVersion = sourceVersion; }
public SybaseParameter (string parameterName, SybaseType dbType, int size, string sourceColumn) : this (parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, sourceColumn, DataRowVersion.Current, null) { }
public SybaseParameter (string parameterName, SybaseType dbType, int size) : this (parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null) { }
// When the SybaseType is set, we also set the DbType, as well as the SQL Server // string representation of the type name. If the SybaseType is not convertible // to a DbType, throw an exception. private void SetSybaseType (SybaseType type) { string exception = String.Format ("No mapping exists from SybaseType {0} to a known DbType.", type); switch (type) { case SybaseType.BigInt: MetaParameter.TypeName = "bigint"; dbType = DbType.Int64; break; case SybaseType.Binary: MetaParameter.TypeName = "binary"; dbType = DbType.Binary; break; case SybaseType.Timestamp: MetaParameter.TypeName = "timestamp"; dbType = DbType.Binary; break; case SybaseType.VarBinary: MetaParameter.TypeName = "varbinary"; dbType = DbType.Binary; break; case SybaseType.Bit: MetaParameter.TypeName = "bit"; dbType = DbType.Boolean; break; case SybaseType.Char: MetaParameter.TypeName = "char"; dbType = DbType.AnsiStringFixedLength; break; case SybaseType.DateTime: MetaParameter.TypeName = "datetime"; dbType = DbType.DateTime; break; case SybaseType.SmallDateTime: MetaParameter.TypeName = "smalldatetime"; dbType = DbType.DateTime; break; case SybaseType.Decimal: MetaParameter.TypeName = "decimal"; dbType = DbType.Decimal; break; case SybaseType.Float: MetaParameter.TypeName = "float"; dbType = DbType.Double; break; case SybaseType.Image: MetaParameter.TypeName = "image"; dbType = DbType.Binary; break; case SybaseType.Int: MetaParameter.TypeName = "int"; dbType = DbType.Int32; break; case SybaseType.Money: MetaParameter.TypeName = "money"; dbType = DbType.Currency; break; case SybaseType.SmallMoney: MetaParameter.TypeName = "smallmoney"; dbType = DbType.Currency; break; case SybaseType.NChar: MetaParameter.TypeName = "nchar"; dbType = DbType.StringFixedLength; break; case SybaseType.NText: MetaParameter.TypeName = "ntext"; dbType = DbType.String; break; case SybaseType.NVarChar: MetaParameter.TypeName = "nvarchar"; dbType = DbType.String; break; case SybaseType.Real: MetaParameter.TypeName = "real"; dbType = DbType.Single; break; case SybaseType.SmallInt: MetaParameter.TypeName = "smallint"; dbType = DbType.Int16; break; case SybaseType.Text: MetaParameter.TypeName = "text"; dbType = DbType.AnsiString; break; case SybaseType.VarChar: MetaParameter.TypeName = "varchar"; dbType = DbType.AnsiString; break; case SybaseType.TinyInt: MetaParameter.TypeName = "tinyint"; dbType = DbType.Byte; break; case SybaseType.UniqueIdentifier: MetaParameter.TypeName = "uniqueidentifier"; dbType = DbType.Guid; break; case SybaseType.Variant: MetaParameter.TypeName = "sql_variant"; dbType = DbType.Object; break; default: throw new ArgumentException (exception); } sybaseType = type; }
// When the DbType is set, we also set the SybaseType, as well as the SQL Server // string representation of the type name. If the DbType is not convertible // to an SybaseType, throw an exception. private void SetDbType (DbType type) { string exception = String.Format ("No mapping exists from DbType {0} to a known SybaseType.", type); switch (type) { case DbType.AnsiString: MetaParameter.TypeName = "varchar"; sybaseType = SybaseType.VarChar; break; case DbType.AnsiStringFixedLength: MetaParameter.TypeName = "char"; sybaseType = SybaseType.Char; break; case DbType.Binary: MetaParameter.TypeName = "varbinary"; sybaseType = SybaseType.VarBinary; break; case DbType.Boolean: MetaParameter.TypeName = "bit"; sybaseType = SybaseType.Bit; break; case DbType.Byte: MetaParameter.TypeName = "tinyint"; sybaseType = SybaseType.TinyInt; break; case DbType.Currency: sybaseType = SybaseType.Money; MetaParameter.TypeName = "money"; break; case DbType.Date: case DbType.DateTime: MetaParameter.TypeName = "datetime"; sybaseType = SybaseType.DateTime; break; case DbType.Decimal: MetaParameter.TypeName = "decimal"; sybaseType = SybaseType.Decimal; break; case DbType.Double: MetaParameter.TypeName = "float"; sybaseType = SybaseType.Float; break; case DbType.Guid: MetaParameter.TypeName = "uniqueidentifier"; sybaseType = SybaseType.UniqueIdentifier; break; case DbType.Int16: MetaParameter.TypeName = "smallint"; sybaseType = SybaseType.SmallInt; break; case DbType.Int32: MetaParameter.TypeName = "int"; sybaseType = SybaseType.Int; break; case DbType.Int64: MetaParameter.TypeName = "bigint"; sybaseType = SybaseType.BigInt; break; case DbType.Object: MetaParameter.TypeName = "sql_variant"; sybaseType = SybaseType.Variant; break; case DbType.Single: MetaParameter.TypeName = "real"; sybaseType = SybaseType.Real; break; case DbType.String: MetaParameter.TypeName = "nvarchar"; sybaseType = SybaseType.NVarChar; break; case DbType.StringFixedLength: MetaParameter.TypeName = "nchar"; sybaseType = SybaseType.NChar; break; case DbType.Time: MetaParameter.TypeName = "datetime"; sybaseType = SybaseType.DateTime; break; default: throw new ArgumentException (exception); } dbType = type; }
object GetSybaseValue(int i) { SybaseType type = (SybaseType)(schemaTable.Rows [i]["ProviderType"]); object value = GetValue(i); switch (type) { case SybaseType.BigInt: if (value == DBNull.Value) { return(SybaseInt64.Null); } return((SybaseInt64)((long)value)); case SybaseType.Binary: case SybaseType.Image: case SybaseType.VarBinary: case SybaseType.Timestamp: if (value == DBNull.Value) { return(SybaseBinary.Null); } return((SybaseBinary)((byte[])value)); case SybaseType.Bit: if (value == DBNull.Value) { return(SybaseBoolean.Null); } return((SybaseBoolean)((bool)value)); case SybaseType.Char: case SybaseType.NChar: case SybaseType.NText: case SybaseType.NVarChar: case SybaseType.Text: case SybaseType.VarChar: if (value == DBNull.Value) { return(SybaseString.Null); } return((SybaseString)((string)value)); case SybaseType.DateTime: case SybaseType.SmallDateTime: if (value == DBNull.Value) { return(SybaseDateTime.Null); } return((SybaseDateTime)((DateTime)value)); case SybaseType.Decimal: if (value == DBNull.Value) { return(SybaseDecimal.Null); } if (value is TdsBigDecimal) { return(SybaseDecimal.FromTdsBigDecimal((TdsBigDecimal)value)); } return((SybaseDecimal)((decimal)value)); case SybaseType.Float: if (value == DBNull.Value) { return(SybaseDouble.Null); } return((SybaseDouble)((double)value)); case SybaseType.Int: if (value == DBNull.Value) { return(SybaseInt32.Null); } return((SybaseInt32)((int)value)); case SybaseType.Money: case SybaseType.SmallMoney: if (value == DBNull.Value) { return(SybaseMoney.Null); } return((SybaseMoney)((decimal)value)); case SybaseType.Real: if (value == DBNull.Value) { return(SybaseSingle.Null); } return((SybaseSingle)((float)value)); case SybaseType.UniqueIdentifier: if (value == DBNull.Value) { return(SybaseGuid.Null); } return((SybaseGuid)((Guid)value)); case SybaseType.SmallInt: if (value == DBNull.Value) { return(SybaseInt16.Null); } return((SybaseInt16)((short)value)); case SybaseType.TinyInt: if (value == DBNull.Value) { return(SybaseByte.Null); } return((SybaseByte)((byte)value)); } throw new InvalidOperationException("The type of this column is unknown."); }
public SybaseParameter Add (string parameterName, SybaseType sybaseType, int size, string sourceColumn) { return Add (new SybaseParameter (parameterName, sybaseType, size, sourceColumn)); }
public SybaseParameter Add (string parameterName, SybaseType sybaseType, int size) { return Add (new SybaseParameter (parameterName, sybaseType, size)); }
public SybaseParameter(string parameterName, SybaseType dbType, int size, string sourceColumn) : this(parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, sourceColumn, DataRowVersion.Current, null) { }
public SybaseParameter(string parameterName, SybaseType dbType, int size) : this(parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null) { }
// When the SybaseType is set, we also set the DbType, as well as the SQL Server // string representation of the type name. If the SybaseType is not convertible // to a DbType, throw an exception. private void SetSybaseType(SybaseType type) { string exception = String.Format("No mapping exists from SybaseType {0} to a known DbType.", type); switch (type) { case SybaseType.BigInt: MetaParameter.TypeName = "bigint"; dbType = DbType.Int64; break; case SybaseType.Binary: MetaParameter.TypeName = "binary"; dbType = DbType.Binary; break; case SybaseType.Timestamp: MetaParameter.TypeName = "timestamp"; dbType = DbType.Binary; break; case SybaseType.VarBinary: MetaParameter.TypeName = "varbinary"; dbType = DbType.Binary; break; case SybaseType.Bit: MetaParameter.TypeName = "bit"; dbType = DbType.Boolean; break; case SybaseType.Char: MetaParameter.TypeName = "char"; dbType = DbType.AnsiStringFixedLength; break; case SybaseType.DateTime: MetaParameter.TypeName = "datetime"; dbType = DbType.DateTime; break; case SybaseType.SmallDateTime: MetaParameter.TypeName = "smalldatetime"; dbType = DbType.DateTime; break; case SybaseType.Decimal: MetaParameter.TypeName = "decimal"; dbType = DbType.Decimal; break; case SybaseType.Float: MetaParameter.TypeName = "float"; dbType = DbType.Double; break; case SybaseType.Image: MetaParameter.TypeName = "image"; dbType = DbType.Binary; break; case SybaseType.Int: MetaParameter.TypeName = "int"; dbType = DbType.Int32; break; case SybaseType.Money: MetaParameter.TypeName = "money"; dbType = DbType.Currency; break; case SybaseType.SmallMoney: MetaParameter.TypeName = "smallmoney"; dbType = DbType.Currency; break; case SybaseType.NChar: MetaParameter.TypeName = "nchar"; dbType = DbType.StringFixedLength; break; case SybaseType.NText: MetaParameter.TypeName = "ntext"; dbType = DbType.String; break; case SybaseType.NVarChar: MetaParameter.TypeName = "nvarchar"; dbType = DbType.String; break; case SybaseType.Real: MetaParameter.TypeName = "real"; dbType = DbType.Single; break; case SybaseType.SmallInt: MetaParameter.TypeName = "smallint"; dbType = DbType.Int16; break; case SybaseType.Text: MetaParameter.TypeName = "text"; dbType = DbType.AnsiString; break; case SybaseType.VarChar: MetaParameter.TypeName = "varchar"; dbType = DbType.AnsiString; break; case SybaseType.TinyInt: MetaParameter.TypeName = "tinyint"; dbType = DbType.Byte; break; case SybaseType.UniqueIdentifier: MetaParameter.TypeName = "uniqueidentifier"; dbType = DbType.Guid; break; case SybaseType.Variant: MetaParameter.TypeName = "sql_variant"; dbType = DbType.Object; break; default: throw new ArgumentException(exception); } sybaseType = type; }
// When the DbType is set, we also set the SybaseType, as well as the SQL Server // string representation of the type name. If the DbType is not convertible // to an SybaseType, throw an exception. private void SetDbType(DbType type) { string exception = String.Format("No mapping exists from DbType {0} to a known SybaseType.", type); switch (type) { case DbType.AnsiString: MetaParameter.TypeName = "varchar"; sybaseType = SybaseType.VarChar; break; case DbType.AnsiStringFixedLength: MetaParameter.TypeName = "char"; sybaseType = SybaseType.Char; break; case DbType.Binary: MetaParameter.TypeName = "varbinary"; sybaseType = SybaseType.VarBinary; break; case DbType.Boolean: MetaParameter.TypeName = "bit"; sybaseType = SybaseType.Bit; break; case DbType.Byte: MetaParameter.TypeName = "tinyint"; sybaseType = SybaseType.TinyInt; break; case DbType.Currency: sybaseType = SybaseType.Money; MetaParameter.TypeName = "money"; break; case DbType.Date: case DbType.DateTime: MetaParameter.TypeName = "datetime"; sybaseType = SybaseType.DateTime; break; case DbType.Decimal: MetaParameter.TypeName = "decimal"; sybaseType = SybaseType.Decimal; break; case DbType.Double: MetaParameter.TypeName = "float"; sybaseType = SybaseType.Float; break; case DbType.Guid: MetaParameter.TypeName = "uniqueidentifier"; sybaseType = SybaseType.UniqueIdentifier; break; case DbType.Int16: MetaParameter.TypeName = "smallint"; sybaseType = SybaseType.SmallInt; break; case DbType.Int32: MetaParameter.TypeName = "int"; sybaseType = SybaseType.Int; break; case DbType.Int64: MetaParameter.TypeName = "bigint"; sybaseType = SybaseType.BigInt; break; case DbType.Object: MetaParameter.TypeName = "sql_variant"; sybaseType = SybaseType.Variant; break; case DbType.Single: MetaParameter.TypeName = "real"; sybaseType = SybaseType.Real; break; case DbType.String: MetaParameter.TypeName = "nvarchar"; sybaseType = SybaseType.NVarChar; break; case DbType.StringFixedLength: MetaParameter.TypeName = "nchar"; sybaseType = SybaseType.NChar; break; case DbType.Time: MetaParameter.TypeName = "datetime"; sybaseType = SybaseType.DateTime; break; default: throw new ArgumentException(exception); } dbType = type; }
/// <summary> /// Please refer to the documentation of <see cref="GentleSqlFactory"/> for details. /// </summary> public override long GetDbType(Type type) { SybaseType result = SybaseType.Int; if (type.Equals(typeof(decimal))) { result = SybaseType.Decimal; } else if (type.Equals(typeof(int))) { result = SybaseType.Int; } else if (type.Equals(typeof(long))) { result = SybaseType.BigInt; } else if (type.Equals(typeof(double))) { result = SybaseType.Decimal; } else if (type.Equals(typeof(DateTime))) { result = SybaseType.DateTime; } else if (type.Equals(typeof(bool))) { result = SybaseType.Bit; } else if (type.Equals(typeof(string))) { result = SybaseType.Text; } else if (type.Equals(typeof(Guid))) { result = SybaseType.UniqueIdentifier; } else { Check.Fail(Error.UnsupportedPropertyType, type.Name, provider.Name); } return((long)result); // AsaDbType result = AsaDbType.Integer; // if( type.Equals(typeof(decimal) ) ) // result = AsaDbType.Decimal; // else if (type.Equals( typeof(int))) // result = AsaDbType.Integer; // else if( type.Equals( typeof(long) ) ) // result = AsaDbType.BigInt; // else if( type.Equals( typeof(double) ) ) // result = AsaDbType.Double; // else if( type.Equals( typeof(DateTime) ) ) // result = AsaDbType.DateTime; // else if( type.Equals( typeof(bool) ) ) // result = AsaDbType.Bit; // else if( type.Equals( typeof(string) ) ) // result = AsaDbType.Text; // else if( type.Equals( typeof(Guid) ) ) // result = AsaDbType.UniqueIdentifierStr; // else // Check.Fail( Error.UnsupportedPropertyType, type.Name, this ); // return (long) result; }