/// <summary> /// Executes the command and returns an array of all of the values of the first column of all rows in the resultset. /// </summary> /// <typeparam name="TItem">The type of data in the first column of each row.</typeparam> /// <param name="command">The command to execute.</param> /// <param name="options">The options that are applied to how arrays are created.</param> /// <returns> /// An array of all of the values of the first column of all of the rows in the resultset. /// </returns> public TItem[] ExecuteArray <TItem>(IDbCommand command, ExecuteArrayOptions options) { var result = new List <TItem>(); using (var reader = this.ExecuteReader(command)) { while (reader.Read()) { var item = reader.GetValue(0); if (ExecuteArrayOptions.IgnoreNullValues == options && (item == System.DBNull.Value || item == null)) { continue; } var value = ChangeType <TItem>(item); result.Add(value); } } return(result.ToArray()); }
/// <summary> /// Executes the query and returns an array of all of the values of the first column of all rows in the resultset. /// </summary> /// <typeparam name="TItem">The type of data in the first column of each row.</typeparam> /// <param name="commandText">The query to execute.</param> /// <param name="options">The options that are applied to how arrays are created.</param> /// <returns> /// An array of all of the values of the first column of all of the rows in the resultset. /// </returns> public TItem[] ExecuteArray <TItem>(string commandText, ExecuteArrayOptions options) { return(this.ExecuteArray <TItem>(CreateCommand(commandText), options)); }
/// <summary> /// Executes the command and returns an array of all of the values of the first column of all rows in the resultset. /// </summary> /// <typeparam name="TItem">The type of data in the first column of each row.</typeparam> /// <param name="command">The command to execute.</param> /// <returns> /// An array of all of the values of the first column of all of the rows in the resultset. /// </returns> public TItem[] ExecuteArray <TItem>(IDbCommand command) { ExecuteArrayOptions options = ExecuteArrayOptions.None; return(ExecuteArray <TItem>(command, options)); }
/// <summary> /// Executes the query and returns an array of all of the values of the first column of all rows in the resultset. /// </summary> /// <typeparam name="TItem">The type of data in the first column of each row.</typeparam> /// <param name="commandText">The query to execute.</param> /// <returns> /// An array of all of the values of the first column of all of the rows in the resultset. /// </returns> public TItem[] ExecuteArray <TItem>(string commandText) { ExecuteArrayOptions options = ExecuteArrayOptions.None; return(ExecuteArray <TItem>(commandText, options)); }