/// <summary> /// Queries the databse for a single database record returning default <typeparamref name="T"/> if not found. /// </summary> /// <param name="dialect">The <see cref="IDbDialect"/>.</param> /// <param name="command">The command to execute.</param> /// <param name="recordBuilder">The record builder that maps an <see cref="IDataRecord"/> to <typeparamref name="T"/>.</param> public static T QuerySingle <T>(this IDbDialect dialect, IDbCommand command, Func <IDataRecord, T> recordBuilder) { return(dialect.ExecuteCommand(command, () => ExecuteReader(command, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow, recordBuilder).SingleOrDefault())); }
/// <summary> /// Executes a SQL statement against a connection object. /// </summary> /// <param name="dialect">The <see cref="IDbDialect"/>.</param> /// <param name="command">The command to execute.</param> public static Int32 ExecuteNonQuery(this IDbDialect dialect, IDbCommand command) { return(dialect.ExecuteCommand(command, command.ExecuteNonQuery)); }
/// <summary> /// Executes the query and returns the first column of the first row in the result set returned by the query. All other columns and rows are ignored. /// </summary> /// <param name="dialect">The <see cref="IDbDialect"/>.</param> /// <param name="command">The command to execute.</param> public static Object ExecuteScalar(this IDbDialect dialect, IDbCommand command) { return(dialect.ExecuteCommand(command, command.ExecuteScalar)); }
/// <summary> /// Queries the databse for a zero or more database records. /// </summary> /// <param name="dialect">The <see cref="IDbDialect"/>.</param> /// <param name="command">The command to execute.</param> /// <param name="recordBuilder">The record builder that maps an <see cref="IDataRecord"/> to <typeparamref name="T"/>.</param> public static List <T> QueryMultiple <T>(this IDbDialect dialect, IDbCommand command, Func <IDataRecord, T> recordBuilder) { return(dialect.ExecuteCommand(command, () => ExecuteReader(command, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult, recordBuilder))); }