private bool IsInitializeSetter(ICommandSetter comToDel, int index) { for (int i = index - 1; i >= 0; i--) { if (_marks[i]) { continue; } if (_commands[i] is ICommandSetter) { if ((_commands[i] as ICommandSetter).TargetName == comToDel.TargetName) { return(false); } } if (_commands[i] is ICommandDeclaration) { if ((_commands[i] as ICommandDeclaration).Name == comToDel.TargetName) { return(true); } } } return(true); }
public CommandsDiscover( ICommandFactory commandFactory, ICommandConvention commandConvention, ICommandSetter commandSetter = null) { CommandFactory = commandFactory; CommandConvention = commandConvention; this.commandSetter = commandSetter ?? new CommandSetter(commandConvention, new CommandBuilder(commandFactory)); }
/// <summary> /// Query database with given SQL command and have each row processed /// by a given <see cref="RowCallbackDelegate"/> with help of optional /// ordinal cache and/or the rows expected value for better performance. /// </summary> /// /// <param name="operations"> /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to /// perform database operation. /// </param> /// <param name="cmdType"> /// The type of command. /// </param> /// <param name="cmdText"> /// The text of command. /// </param> /// <param name="rowCallbackDelegate"> /// The row callback delegate that processes each row. /// </param> /// <param name="commandSetter"> /// The command setter that make necessary changes to the /// <see cref="IDbCommand"/> object before it is executed. /// For example, set the parameters. /// </param> /// <param name="ordinalCache"> /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping /// from field name to field index. /// </param> /// <param name="rowsExpected"> /// Number of rows this query is expected to return. This doesn't need /// to be accurate but estimating at the higer end for best performance. /// </param> public static void QueryWithRowCallbackDelegate( this IAdoOperations operations, CommandType cmdType, string cmdText, RowCallbackDelegate rowCallbackDelegate, ICommandSetter commandSetter, IDataRecordOrdinalCache ordinalCache, int rowsExpected) { var extractor = MakeResultSetExtractor(rowCallbackDelegate, ordinalCache, rowsExpected); operations.QueryWithResultSetExtractor(cmdType, cmdText, extractor, commandSetter); }
/// <summary> /// Query database with given SQL command and mapping each row to a /// object via a <see cref="RowMapperDelegate{T}"/> with help of optional /// ordinal cache and/or the rows expected value for better performance. /// </summary> /// <typeparam name="T">The type of object that each row maps to.</typeparam> /// <param name="operations"> /// An <see cref="Spring.Data.Generic.IAdoOperations"/> object to /// perform database operation. /// </param> /// <param name="cmdType"> /// The type of command. /// </param> /// <param name="cmdText"> /// The text of command. /// </param> /// <param name="rowMapperDelegate"> /// The row mapper delegate that maps each row to object of type /// <typeparamref name="T"/>. /// </param> /// <param name="commandSetter"> /// The command setter that make necessary changes to the /// <see cref="IDbCommand"/> object before it is executed. /// For example, set the parameters. /// </param> /// <param name="ordinalCache"> /// The <see cref="IDataRecordOrdinalCache"/> that caches the mapping /// from field name to field index. /// </param> /// <param name="rowsExpected"> /// Number of rows this query is expected to return. This doesn't need /// to be accurate but estimating at the higer end for best performance. /// </param> /// <returns> /// A list of object of type <typeparamref name="T"/> that were mapped /// for the rows. /// </returns> public static IList <T> QueryWithRowMapperDelegate <T>( this IAdoOperations operations, CommandType cmdType, string cmdText, RowMapperDelegate <T> rowMapperDelegate, ICommandSetter commandSetter, IDataRecordOrdinalCache ordinalCache, int rowsExpected) { var extractor = MakeResultSetExtractor(rowMapperDelegate, ordinalCache, rowsExpected); return(operations.QueryWithResultSetExtractor(cmdType, cmdText, extractor, commandSetter)); }
private bool ExecuteNonQueryCallback(CommandType cmdType, string cmdText, ICommandSetter setter) { if (cmdType != _cmdType) { return(false); } if (cmdText != _sql) { return(false); } OracleCommand command = new OracleCommand(); setter.SetValues(command); object[] stringFields = (object[])command.Parameters["string_field"].Value; object[] intFields = (object[])command.Parameters["int_field"].Value; for (int i = 0; i < command.ArrayBindCount; i++) { _dataSaved.Add((string)stringFields[i], (int)intFields[i]); } return(true); }
private bool IsInitializeSetter(ICommandSetter comToDel, int index) { for (int i = index - 1; i >= 0; i--) { if (_marks[i]) continue; if (_commands[i] is ICommandSetter) { if ((_commands[i] as ICommandSetter).TargetName == comToDel.TargetName) return false; } if (_commands[i] is ICommandDeclaration) { if ((_commands[i] as ICommandDeclaration).Name == comToDel.TargetName) return true; } } return true; }
/// <summary> /// Execute a query with the specified command text and parameters set via the /// command setter, mapping a single result row to an object via a RowMapper. /// </summary> /// <param name="cmdType">The command type.</param> /// <param name="cmdText">The command text to execute.</param> /// <param name="rowMapperDelegate">delegate that will map one object per row</param> /// <param name="commandSetter">The command setter.</param> /// <returns>The single mapped object.</returns> /// <exception cref="Spring.Dao.IncorrectResultSizeDataAccessException"> /// If the query does not return exactly one row. /// </exception> /// <exception cref="Spring.Dao.DataAccessException"> /// If there is any problem executing the query. /// </exception> public virtual object QueryForObjectDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, ICommandSetter commandSetter) { IList results = QueryWithRowMapperDelegate(cmdType, cmdText, rowMapperDelegate, commandSetter); return DataAccessUtils.RequiredUniqueResultSet(results); }
public virtual object QueryWithResultSetExtractorDelegate(CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, ICommandSetter commandSetter) { AssertUtils.ArgumentNotNull(resultSetExtractorDelegate, "resultSetExtractorDelegate", "Result set extractor delegate must not be null"); return Execute(new QueryCallbackWithCommandSetter(this, cmdType, cmdText, resultSetExtractorDelegate, commandSetter)); }
public virtual IList QueryWithRowMapperDelegate(CommandType cmdType, string cmdText, RowMapperDelegate rowMapperDelegate, ICommandSetter commandSetter) { return (IList)QueryWithResultSetExtractor(cmdType, cmdText, new RowMapperResultSetExtractor(rowMapperDelegate), commandSetter); }
public virtual void QueryWithRowCallbackDelegate(CommandType cmdType, string sql, RowCallbackDelegate rowCallbackDelegate, ICommandSetter commandSetter) { QueryWithResultSetExtractor(cmdType, sql, new RowCallbackResultSetExtractor(rowCallbackDelegate), commandSetter); }
/// <summary> /// Execute a query given IDbCommand's type and text by /// passing the created IDbCommand to a ICommandSetter implementation /// that knows how to bind values to the IDbCommand, reading a /// single result set on a per-row basis with a <see cref="IRowCallback"/>. /// </summary> /// <param name="cmdType">The type of command</param> /// <param name="cmdText">The text of the query.</param> /// <param name="rowCallback">callback that will extract results /// one row at a time. /// </param> /// <param name="commandSetter">The command setter.</param> public virtual void QueryWithRowCallback(CommandType cmdType, string cmdText, IRowCallback rowCallback, ICommandSetter commandSetter) { QueryWithResultSetExtractor(cmdType, cmdText, new RowCallbackResultSetExtractor(rowCallback), commandSetter); }
/// <summary> /// Execute the query with the specified command text and parameters set via the /// command setter, returning a scalar result /// </summary> /// <param name="cmdType">The command type</param> /// <param name="cmdText">The command text to execute.</param> /// <param name="commandSetter">The command setter.</param> /// <returns>The first column of the first row in the result set</returns> public virtual object ExecuteScalar(CommandType cmdType, string cmdText, ICommandSetter commandSetter) { #region Instrumentation if (LOG.IsDebugEnabled) { LOG.Debug("Executing ExecuteScalar. " + cmdType + "[" + cmdText + "]"); } #endregion return Execute(new ExecuteScalarCallbackWithCommandSetter(cmdType, cmdText, commandSetter)); }
/// <summary> /// Executes a non query with parameters set via the /// command setter, returning the number of rows affected. /// </summary> /// <param name="cmdType">The command type.</param> /// <param name="cmdText">The command text to execute.</param> /// <param name="commandSetter">The command setter.</param> /// <returns>The number of rows affected.</returns> public virtual int ExecuteNonQuery(CommandType cmdType, string cmdText, ICommandSetter commandSetter) { #region Instrumentation if (LOG.IsDebugEnabled) { LOG.Debug("Executing NonQuery. " + cmdType + "[" + cmdText + "]"); } #endregion return (int)Execute(new ExecuteNonQueryCallbackWithCommandSetter(cmdType, cmdText, commandSetter)); }
public QueryCallbackWithCommandSetter(AdoTemplate adoTemplate, CommandType cmdType, string cmdText, ResultSetExtractorDelegate resultSetExtractorDelegate, ICommandSetter commandSetter) { this.adoTemplate = adoTemplate; commandType = cmdType; commandText = cmdText; this.resultSetExtractorDelegate = resultSetExtractorDelegate; this.commandSetter = commandSetter; }
public ExecuteScalarCallbackWithCommandSetter(CommandType commandType, string commandText, ICommandSetter commandSetter) { this.commandType = commandType; this.commandText = commandText; this.commandSetter = commandSetter; }
public CommandFactory(ICommandSetter <DeactivateAccountBuilder> deactivateAccountSetter) { _deactivateAccountSetter = deactivateAccountSetter; }