Пример #1
0
 /// <summary>
 /// Execute SELECT SQL query and return IEnumerable of dynamic object
 /// </summary>
 /// <param name="connectionString">Connection string to database</param>
 /// <param name="sql">Any SELECT SQL that you want to perform with/without parameterized parameters (Do not directly put sql parameter in this parameter)</param>
 /// <param name="parameters">SQL parameters according to the sql parameter</param>
 /// <param name="commandType">Type of SQL Command</param>
 /// <returns>IEnumerable of dynamic object</returns>
 /// <exception cref="Exception"/>
 public static async Task <IEnumerable <dynamic> > ExecuteReaderAsync(string connectionString, string sql, IEnumerable <SqlParameter> parameters = null, System.Data.CommandType commandType = System.Data.CommandType.Text)
 {
     return(await DbConnectionBase.ExecuteReaderAsync <SqlConnection>(connectionString, sql, parameters, commandType));
 }
Пример #2
0
 /// <summary>
 /// Execute SELECT SQL query and return IEnumerable of specified POCO that is matching with the query columns
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="connectionString">Connection string to database</param>
 /// <param name="sql">Any SELECT SQL that you want to perform with/without parameterized parameters (Do not directly put sql parameter in this parameter)</param>
 /// <param name="parameters">SQL parameters according to the sql parameter</param>
 /// <param name="objectBuilder">How the POCO should build with each giving row of SqlDataReader</param>
 /// <param name="commandType">Type of SQL Command</param>
 /// <returns>IEnumerable of POCO</returns>
 /// <exception cref="Exception"/>
 public static async Task <IEnumerable <T> > ExecuteReaderAsync <T>(string connectionString, string sql, IEnumerable <SqlParameter> parameters, Func <DbDataReader, T> objectBuilder, System.Data.CommandType commandType = System.Data.CommandType.Text) where T : new()
 {
     return(await DbConnectionBase.ExecuteReaderAsync <T, SqlConnection>(connectionString, sql, parameters, objectBuilder, commandType));
 }