/// <summary> /// Create an IDbCommand for the SqlMapSession and the current SQL Statement /// and fill IDbCommand IDataParameter's with the parameterObject. /// </summary> /// <param name="request"></param> /// <param name="session">The SqlMapSession</param> /// <param name="statement">The IStatement</param> /// <param name="parameterObject"> /// The parameter object that will fill the sql parameter /// </param> /// <returns>An IDbCommand with all the IDataParameter filled.</returns> public void Create(RequestScope request, ISqlMapSession session, IStatement statement, object parameterObject) { // the IDbConnection & the IDbTransaction are assign in the CreateCommand request.DbCommand = new DbCommandDecorator(session.CreateCommand(statement.CommandType), request); request.DbCommand.CommandText = request.PreparedStatement.PreparedSql; ApplyParameterMap(session, request.DbCommand, request, statement, parameterObject); }
public void Create(RequestScope request, ISqlMapSession session, IStatement statement, object parameterObject) { request.IDbCommand = new DbCommandDecorator(session.CreateCommand(statement.CommandType), request); request.IDbCommand.CommandText = request.PreparedStatement.PreparedSql; if (_logger.IsDebugEnabled) { _logger.Debug("Statement Id: [" + statement.Id + "] PreparedStatement : [" + request.IDbCommand.CommandText + "]"); } this.ApplyParameterMap(session, request.IDbCommand, request, statement, parameterObject); }
/// <summary> /// Create an IDbCommand for the SqlMapSession and the current SQL Statement /// and fill IDbCommand IDataParameter's with the parameterObject. /// </summary> /// <param name="request"></param> /// <param name="session">The SqlMapSession</param> /// <param name="statement">The IStatement</param> /// <param name="parameterObject"> /// The parameter object that will fill the sql parameter /// </param> /// <returns>An IDbCommand with all the IDataParameter filled.</returns> public void Create(RequestScope request, ISqlMapSession session, IStatement statement, object parameterObject ) { // the IDbConnection & the IDbTransaction are assign in the CreateCommand request.IDbCommand = new DbCommandDecorator(session.CreateCommand(statement.CommandType), request); request.IDbCommand.CommandText = request.PreparedStatement.PreparedSql; if (_logger.IsDebugEnabled) { _logger.Debug("Statement Id: [" + statement.Id + "] PreparedStatement : [" + request.IDbCommand.CommandText + "]"); } ApplyParameterMap( session, request.IDbCommand, request, statement, parameterObject ); }
/// <summary> /// Create an IDbCommand for the SqlMapSession and the current SQL Statement /// and fill IDbCommand IDataParameter's with the parameterObject. /// </summary> /// <param name="request"></param> /// <param name="session">The SqlMapSession</param> /// <param name="statement">The IStatement</param> /// <param name="parameterObject"> /// The parameter object that will fill the sql parameter /// </param> /// <returns>An IDbCommand with all the IDataParameter filled.</returns> public void Create(RequestScope request, ISqlMapSession session, IStatement statement, object parameterObject) { // the IDbConnection & the IDbTransaction are assign in the CreateCommand request.IDbCommand = new DbCommandDecorator(session.CreateCommand(statement.CommandType), request); request.IDbCommand.CommandText = request.PreparedStatement.PreparedSql; if (Logger.IsDebugEnabled) { Logger.Debug("Statement Id: [" + statement.Id + "] PreparedStatement : [" + request.IDbCommand.CommandText + "]"); } ApplyParameterMap(session, request.IDbCommand, request, statement, parameterObject); }
/// <summary> /// Create IDataParameters for procedure statement. /// </summary> private void CreateParametersForProcedureCommand() { string sqlParamName = string.Empty; string dbTypePropertyName = _session.DataSource.DbProvider.ParameterDbTypeProperty; Type enumDbType = _session.DataSource.DbProvider.ParameterDbType; ParameterPropertyCollection list = null; if (_session.DataSource.DbProvider.UsePositionalParameters) //obdc/oledb { list = _request.ParameterMap.Properties; } else { list = _request.ParameterMap.PropertiesList; } _preparedStatement.DbParameters = new IDbDataParameter[list.Count]; // ParemeterMap are required for procedure and we tested existance in Prepare() method // so we don't have to test existence here. // A ParameterMap used in CreateParametersForProcedureText must // have property and column attributes set. // The column attribute is the name of a procedure parameter. for (int i = 0; i < list.Count; i++) { ParameterProperty property = list[i]; if (_session.DataSource.DbProvider.UseParameterPrefixInParameter) { sqlParamName = _parameterPrefix + property.ColumnName; } else //obdc/oledb { sqlParamName = property.ColumnName; } IDbDataParameter dataParameter = _session.CreateCommand(_statement.CommandType).CreateParameter(); // Manage dbType attribute if any if (property.DbType != null && property.DbType.Length > 0) { // Exemple : Enum.parse(System.Data.SqlDbType, 'VarChar') object dbType = Enum.Parse(enumDbType, property.DbType, true); // Exemple : ObjectHelper.SetProperty(sqlparameter, 'SqlDbType', SqlDbType.Int); ObjectProbe.SetMemberValue(dataParameter, dbTypePropertyName, dbType, _request.DataExchangeFactory.ObjectFactory, _request.DataExchangeFactory.AccessorFactory); } // Set IDbDataParameter // JIRA-49 Fixes (size, precision, and scale) if (_session.DataSource.DbProvider.SetDbParameterSize) { if (property.Size != -1) { dataParameter.Size = property.Size; } } if (_session.DataSource.DbProvider.SetDbParameterPrecision) { dataParameter.Precision = property.Precision; } if (_session.DataSource.DbProvider.SetDbParameterScale) { dataParameter.Scale = property.Scale; } // Set as direction parameter dataParameter.Direction = property.Direction; dataParameter.ParameterName = sqlParamName; _preparedStatement.DbParametersName.Add(property.PropertyName); _preparedStatement.DbParameters[i] = dataParameter; if (_session.DataSource.DbProvider.UsePositionalParameters == false) { _propertyDbParameterMap.Add(property, dataParameter); } } }