// Used from SqlServerCeDriver as well public static void SetParameterSizes(IDataParameterCollection parameters, SqlType[] parameterTypes) { for (int i = 0; i < parameters.Count; i++) { SetVariableLengthParameterSize((IDbDataParameter) parameters[i], parameterTypes[i]); } }
private static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType sqlType) { switch (dbParam.DbType) { case DbType.AnsiString: case DbType.AnsiStringFixedLength: dbParam.Size = MaxAnsiStringSize; break; case DbType.Binary: if (sqlType is BinaryBlobSqlType) { dbParam.Size = MaxBinaryBlobSize; } else { dbParam.Size = MaxBinarySize; } break; case DbType.Decimal: dbParam.Precision = MaxPrecision; dbParam.Scale = MaxScale; break; case DbType.String: case DbType.StringFixedLength: dbParam.Size = IsText(dbParam, sqlType) ? MaxStringClobSize : MaxStringSize; break; case DbType.DateTime2: dbParam.Size = MaxDateTime2; break; case DbType.DateTimeOffset: dbParam.Size = MaxDateTimeOffset; break; } }
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { if (sqlType is NpgsqlExtendedSqlType && dbParam is NpgsqlParameter) this.InitializeParameter(dbParam as NpgsqlParameter, name, sqlType as NpgsqlExtendedSqlType); else base.InitializeParameter(dbParam, name, sqlType); }
public override string GetTypeName(SqlType sqlType) { if (IsUnallowedDecimal(sqlType.DbType, sqlType.Precision)) return base.GetTypeName(new SqlType(sqlType.DbType, MAX_DECIMAL_PRECISION, sqlType.Scale)); return base.GetTypeName(sqlType); }
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { var convertedSqlType = sqlType; if (convertedSqlType.DbType == DbType.Currency) convertedSqlType = new SqlType(DbType.Decimal); base.InitializeParameter(dbParam, name, convertedSqlType); }
public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { IDbCommand command = base.GenerateCommand(type, sqlString, parameterTypes); SetParameterSizes(command.Parameters, parameterTypes); return command; }
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); if (sqlType is StringClobSqlType) { ((OracleParameter)dbParam).OracleType = OracleType.NClob; } }
public override string GetTypeName(SqlType sqlType, int length, int precision, int scale) { var fbDecimalPrecision = precision; if (IsUnallowedDecimal(sqlType.DbType, precision)) fbDecimalPrecision = MAX_DECIMAL_PRECISION; return base.GetTypeName(sqlType, length, fbDecimalPrecision, scale); }
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); if (sqlType.LengthDefined) { dbParam.Size = sqlType.Length; } }
public SqlDeleteBuilder AddWhereFragment(string columnName, SqlType type, string op) { if (!string.IsNullOrEmpty(columnName)) { whereStrings.Add(ToWhereString(columnName, op)); parameterTypes.Add(type); } return this; }
public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { IDbCommand command = base.GenerateCommand(type, sqlString, parameterTypes); if (IsPrepareSqlEnabled) { SetParameterSizes(command.Parameters, parameterTypes); } return command; }
public IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { var innerCommand = _innerDriver.GenerateCommand(type, sqlString, parameterTypes); if (innerCommand is GlimpseProfileDbCommand) return innerCommand; var command = new GlimpseProfileDbCommand(innerCommand as DbCommand, _stats); return command; }
private static SqlType AdjustSqlType(SqlType sqlType) { switch (sqlType.DbType) { case DbType.Guid: return GuidSqlType; default: return sqlType; } }
public override IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { IDbCommand command = base.GenerateCommand(type, sqlString, parameterTypes); if (prepareSql) { SqlClientDriver.SetParameterSizes(command.Parameters, parameterTypes); } return command; }
/// <remarks> /// This adds logic to ensure that a DbType.Boolean parameter is not created since /// ODP.NET doesn't support it. /// </remarks> protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { // if the parameter coming in contains a boolean then we need to convert it // to another type since ODP.NET doesn't support DbType.Boolean if (sqlType.DbType == DbType.Boolean) { sqlType = SqlTypeFactory.Int16; } base.InitializeParameter(dbParam, name, sqlType); }
public IDbCommand Generate(CommandType type, SqlString sqlString, SqlType[] parameterTypes) { IDbCommand cmd = factory.ConnectionProvider.Driver.GenerateCommand(type, sqlString, parameterTypes); LogOpenPreparedCommand(); if (log.IsDebugEnabled) { log.Debug("Building an IDbCommand object for the SqlString: " + sqlString.ToString()); } commandsToClose.Add(cmd); return cmd; }
protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { if (sqlType.DbType == DbType.Guid) { base.InitializeParameter(dbParam, name, GuidSqlType); } else { base.InitializeParameter(dbParam, name, sqlType); } }
public OutputParamReturningDelegate(IPostInsertIdentityPersister persister, ISessionFactoryImplementor factory) : base(persister) { if (Persister.RootTableKeyColumnNames.Length > 1) { throw new HibernateException("identity-style generator cannot be used with multi-column keys"); } paramType = Persister.IdentifierType.SqlTypes(factory)[0]; idColumnName = Persister.RootTableKeyColumnNames[0]; this.factory = factory; }
private static Parameter[ ] GenerateValueParameters( string prefix, SqlType sqlType, int count ) { Parameter[ ] parameters = new Parameter[count]; for( int i = 0; i < count; i++ ) { string parameterName = StringHelper.Suffix( prefix, StringHelper.Underscore + i.ToString() ); parameters[ i ] = new Parameter( parameterName, sqlType ); } return parameters; }
/// <summary> /// Initializes a new instance of <see cref="Parameter"/> class. /// </summary> /// <param name="name">The name of the parameter.</param> /// <param name="tableAlias">The Alias to use for the table.</param> /// <param name="sqlType">The <see cref="SqlType"/> to create the parameter for.</param> public Parameter(string name, string tableAlias, SqlType sqlType) { if( tableAlias!=null && tableAlias.Length>0 ) { _name = tableAlias + StringHelper.Dot + name; } else { _name = name; } _sqlType = sqlType; }
/// <summary> /// Initializes the parameter. /// </summary> /// <param name="dbParam">The db param.</param> /// <param name="name">The name.</param> /// <param name="sqlType">Type of the SQL.</param> protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); if ((sqlType is StringClobSqlType)) { ReflectHelper.TypeFromAssembly(OracleParameterType, DriverAssemblyName, false) .GetProperty("OracleDbType") .SetValue(dbParam, Enum.Parse(ReflectHelper.TypeFromAssembly(OracleDbType, DriverAssemblyName, false), "NClob"), null); } }
protected override void InitializeParameter(IDbDataParameter dbParam,string name,SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); var stringType = sqlType as StringSqlType; if (stringType != null && stringType.LengthDefined && stringType.Length > 4000) { var parameter = (SqlCeParameter)dbParam; parameter.SqlDbType = SqlDbType.NText; } }
public bool SupportsSqlType(SqlType sqlType) { try { dialect.GetTypeName(sqlType); return true; } catch { return false; } }
protected AbstractEnumType(SqlType sqlType,System.Type enumType) : base(sqlType) { if (enumType.IsEnum) { this.enumType = enumType; } else { throw new MappingException(enumType.Name + " did not inherit from System.Enum"); } defaultValue = Enum.GetValues(enumType).GetValue(0); }
protected override void InitializeParameter( IDbDataParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); if (sqlType is StringClobSqlType) { var parameter = (SqlCeParameter)dbParam; parameter.SqlDbType = SqlDbType.NText; } }
private static void SetVariableLengthParameterSize(IDbDataParameter dbParam, SqlType sqlType) { // Override the defaults using data from SqlType. if (sqlType.LengthDefined) { dbParam.Size = sqlType.Length; } if (sqlType.PrecisionDefined) { dbParam.Precision = sqlType.Precision; dbParam.Scale = sqlType.Scale; } }
public override SqlType[] SqlTypes(IMapping mapping) { //Not called at runtime so doesn't matter if its slow :) SqlType[] sqlTypes = new SqlType[GetColumnSpan(mapping)]; int n = 0; for (int i = 0; i < propertySpan; i++) { SqlType[] subtypes = propertyTypes[i].SqlTypes(mapping); for (int j = 0; j < subtypes.Length; j++) { sqlTypes[n++] = subtypes[j]; } } return sqlTypes; }
/// <summary> /// Get the name of the database type associated with the given /// <see cref="SqlTypes.SqlType"/>, /// </summary> /// <param name="sqlType">The SqlType</param> /// <returns>The database type name used by ddl.</returns> public virtual string GetTypeName( SqlType sqlType ) { if( sqlType.LengthDefined ) { string resultWithLength = typeNames.Get( sqlType.DbType, sqlType.Length ); if( resultWithLength != null ) return resultWithLength; } string result = typeNames.Get( sqlType.DbType ); if( result == null ) { throw new HibernateException( "No default type mapping for SqlType " + sqlType.ToString() ); } return result; }
/// <remarks> /// This adds logic to ensure that a DbType.Boolean parameter is not created since /// ODP.NET doesn't support it. /// </remarks> protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType) { // if the parameter coming in contains a boolean then we need to convert it // to another type since ODP.NET doesn't support DbType.Boolean switch (sqlType.DbType) { case DbType.Boolean: base.InitializeParameter(dbParam, name, SqlTypeFactory.Int16); break; case DbType.Guid: base.InitializeParameter(dbParam, name, GuidSqlType); break; default: base.InitializeParameter(dbParam, name, sqlType); break; } }
protected override void InitializeParameter(System.Data.IDbDataParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); //http://thebasilet.blogspot.be/2009/07/nhibernate-oracle-clobs.html //System.Data.OracleClient.dll driver generates an exception //we set the IDbDataParameter.Value = (string whose length: 4000 > length > 2000 ) //when we set the IDbDataParameter.DbType = DbType.String //when DB Column is of type NCLOB/CLOB //The Above is the default behavior for NHibernate.OracleClientDriver //So we use the built-in StringClobSqlType to tell the driver to use the NClob Oracle type //This will work for both NCLOB/CLOBs without issues. //Mapping file will need to be update to use StringClob as the property type if ((sqlType is StringClobSqlType)) { ((OracleParameter)dbParam).OracleType = OracleType.NClob; } }