/// <summary> /// ChoiceBasedExecuteOneAsync /// </summary> /// <param name="sqlQuery">The Incoming-Sql (Raw-Sql/Stored-Procedure)</param> /// <param name="queryParams">The Sql-Parameters</param> /// <param name="conBroker">The Connection-Broker</param> /// <returns>The Count-Of-Executed-And-Affected-Rows</returns> public async Task <int> ChoiceBasedExecuteOneAsync(string sqlQuery, DynamicParameters queryParams, ConnectionBroker conBroker) { int affectedRows = 0; if (conBroker != null) { switch (conBroker.TargetedDatabase) { case TargetDbType.OracleMySQL: //OracleMySql Server using (MySqlConnection con = new MySqlConnection(conBroker.TheValue)) { affectedRows = await con.ExecuteAsync(sql : sqlQuery, param : queryParams); } break; default: //Microsoft SQL Server using (IDbConnection con = new SqlConnection(conBroker.TheValue)) { affectedRows = await con.ExecuteAsync(sql : sqlQuery, param : queryParams, commandType : CommandType.StoredProcedure); } break; } } return(affectedRows); }
/// <summary> /// ChoiceBasedExecuteAsync /// </summary> /// <param name="sqlQuery">The Incoming-Sql (Raw-Sql/Stored-Procedure)</param> /// <param name="queryParams">The Sql-Parameters</param> /// <param name="connectionBroker">The Connection-Broker</param> /// <returns>The Choice-Based-Executed 01-List</returns> public async Task <List <TEntity> > ChoiceBasedExecuteAsync(string sqlQuery, DynamicParameters queryParams, ConnectionBroker connectionBroker) { List <TEntity> dummyList = new List <TEntity>(); if (connectionBroker != null) { switch (connectionBroker.TargetedDatabase) { case TargetDbType.OracleMySQL: using (MySqlConnection db = new MySqlConnection(connectionBroker.TheValue)) { dummyList = (List <TEntity>) await db.QueryAsync <TEntity>(sql : sqlQuery, param : queryParams); } break; default: bool storeProcedureExist = GeneralCommand.StoredProcedureExist(connectionBroker.NakedID, sqlQuery); if (storeProcedureExist) { using IDbConnection db = new SqlConnection(connectionBroker.TheValue); dummyList = (List <TEntity>) await db.QueryAsync <TEntity>(sql : sqlQuery, param : queryParams, commandType : CommandType.StoredProcedure); } break; } } return(dummyList); }