public GxMySQLConnectorCursorDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) { this.parameters = parameters; this.stmt = stmt; this.fetchSize = fetchSize; this.cache = connection.ConnectionCache; this.cached = cached; this.handle = handle; this.isForFirst = forFirst; _connManager = connManager; this.m_dr = dr; this.readBytes = 0; this.dynStmt = dynStmt; con = _connManager.IncOpenHandles(handle, m_dr.DataSource); con.CurrentStmt = stmt; con.MonitorEnter(); GXLogging.Debug(log, "Open GxMySQLCursorDataReader handle:'" + handle); MySQLCommand cmd = (MySQLCommand)dr.GetCommand(con, stmt, parameters); reader = cmd.ExecuteReader(); cache.SetAvailableCommand(stmt, false, dynStmt); open = true; block = new GxArrayList(fetchSize); pos = -1; if (cached) { key = SqlUtil.GetKeyStmtValues(parameters, stmt, isForFirst); this.expiration = expiration; } }
/// <inheritdoc /> public ResultSet <T> Select <T>(string query, Dictionary <string, dynamic> bindings = null) where T : Model <T>, new() { using var connection = new Connection(ConnectionString); connection.Open(); using var command = new Command(query, connection); BindParameters(command, bindings); using var reader = command.ExecuteReader(); ResultSet <T> resultSet = new ResultSet <T>(); if (Manager.DebugMode) { Manager.Logger(query); } while (reader.Read()) { ResultRow <T> resultRow = new ResultRow <T>(); for (int column = 0; column < reader.FieldCount; column++) { resultRow.Columns.Add(reader.GetName(column), reader.GetValue(column)); } resultSet.Rows.Add(resultRow); } return(resultSet); }