/// <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="commandType">Type of SQL Command</param> /// <returns>IEnumerable of POCO</returns> /// <exception cref="Exception"/> public static IEnumerable <T> ExecuteReader <T>(string connectionString, string sql, IEnumerable <SqlParameter> parameters = null, System.Data.CommandType commandType = System.Data.CommandType.Text) where T : new() { return(DbConnectionBase.ExecuteReader <T, SqlConnection>(connectionString, sql, parameters, (cursor) => Data.RowBuilder <T>(cursor), commandType)); }
/// <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 IEnumerable <dynamic> ExecuteReader(string connectionString, string sql, IEnumerable <SqlParameter> parameters = null, System.Data.CommandType commandType = System.Data.CommandType.Text) { return(DbConnectionBase.ExecuteReader <SqlConnection>(connectionString, sql, parameters, commandType)); }
/// <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 IEnumerable <T> ExecuteReader <T>(string connectionString, string sql, IEnumerable <SqlParameter> parameters, Func <DbDataReader, T> objectBuilder, System.Data.CommandType commandType = System.Data.CommandType.Text) where T : new() { return(DbConnectionBase.ExecuteReader <T, SqlConnection>(connectionString, sql, parameters, objectBuilder, commandType)); }