public override string AfterCreateCommand(string stmt, GxParameterCollection parmBinds) { if (parmBinds == null || parmBinds.Count == 0 || stmt.IndexOf('?') < 0) { return(stmt); } bool inString = false; int parmIndex = 0; StringBuilder sBld = new StringBuilder(); for (int i = 0; i < stmt.Length; i++) { char c = stmt[i]; if (c == '`') { inString = !inString; sBld.Append(c); } else if (c == '?' && !inString) { sBld.Append('@'); sBld.Append(parmBinds[parmIndex].ParameterName); parmIndex++; } else { sBld.Append(c); } } return(sBld.ToString()); }
public override IDataReader GetDataReader( IGxConnectionManager connManager, IGxConnection con, GxParameterCollection parameters, string stmt, ushort fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) { IDataReader idatareader; if (NpgsqlAssembly.GetName().Version.Major == 1) { GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode()); idatareader = new GxDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt); } else { if (!hasNested) //Client Cursor { GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode()); idatareader = new GxDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt); } else //Server Cursor { GXLogging.Debug(log, "ExecuteReader: server cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode()); idatareader = new GxPostgresqlMemoryDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt); } } return(idatareader); }
public override void SetParameterDir(GxParameterCollection parameters, int num, ParameterDirection dir) { if (dir == ParameterDirection.Output) { parameters[num].Direction = ParameterDirection.ReturnValue; } else { parameters[num].Direction = dir; } }
public override IDbCommand GetCommand(IGxConnection con, string stmt, GxParameterCollection parameters) { IDbCommand cmd = base.GetCommand(con, stmt, parameters); IServiceCommand iCmd = cmd as IServiceCommand; if (iCmd != null) { iCmd.CursorDef = m_CursorDef; } return(cmd); }
public override IDbCommand GetCommand(IGxConnection con, string stmt, GxParameterCollection parameters, bool isCursor, bool forFirst, bool isRpc) { if (isRpc) { stmt = convertToMySqlCall(stmt, parameters); } MySQLCommand mysqlcmd = (MySQLCommand)base.GetCommand(con, stmt, parameters.Distinct()); if (isCursor && !isRpc) { mysqlcmd.Prepare(); } return(mysqlcmd); }
public override IDataReader GetDataReader( IGxConnectionManager connManager, IGxConnection con, GxParameterCollection parameters, string stmt, ushort fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) { IDataReader idatareader; idatareader = new GxDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt); return(idatareader); }
public override IDataReader GetDataReader( IGxConnectionManager connManager, IGxConnection con, GxParameterCollection parameters, string stmt, ushort fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) { IDataReader idatareader; GXLogging.Debug(log, "ExecuteReader: client cursor=", () => hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode()); idatareader = new GxDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt); return(idatareader); }
public override IDbCommand GetCommand(IGxConnection con, string stmt, GxParameterCollection parameters, bool isCursor, bool forFirst, bool isRpc) { if (isRpc) { stmt = convertToMySqlCall(stmt, parameters); } MySQLCommand mysqlcmd = (MySQLCommand)base.GetCommand(con, stmt, parameters); if (preparedStmts && isCursor && !isRpc) { #if !NETCORE mysqlcmd.UsePreparedStatement = true; #endif mysqlcmd.Prepare(); } return(mysqlcmd); }
public MemoryDataReader(IDataReader reader, IGxConnection connection, GxParameterCollection parameters, string stmt, ushort fetchSize, bool isForFirst, bool withCached, SlidingTime expiration) : this() { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (reader.IsClosed) { throw new ArgumentException("Reader is closed"); } DataTable schemaTab = reader.GetSchemaTable(); if (schemaTab != null) { this._schemaDataTable = schemaTab.Clone(); } string[] colnames = null; while (reader.Read()) { if (colnames == null) { colnames = new string[reader.FieldCount]; for (int fi = 0; fi < colnames.Length; fi++) { colnames[fi] = reader.GetName(fi); } } this.AddRecord(reader, colnames); } this.cached = withCached; this.con = connection; block = new GxArrayList(fetchSize); if (cached) { this.key = SqlUtil.GetKeyStmtValues(parameters, stmt, isForFirst); this.expiration = expiration; } }
public override IDataReader GetDataReader( IGxConnectionManager connManager, IGxConnection con, GxParameterCollection parameters, string stmt, ushort fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) { IDataReader idatareader; #if !NETCORE GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode() + " PreparedStmt " + preparedStmts); if (preparedStmts) { idatareader = new GxMySQLCursorDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, hasNested, dynStmt); } else { idatareader = new GxMySQLDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt, preparedStmts); } #else if (!hasNested)//Client Cursor { GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode() + " PreparedStmt " + preparedStmts); if (preparedStmts) { idatareader = new GxMySQLCursorDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, hasNested, dynStmt); } else { idatareader = new GxMySQLDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt, preparedStmts); } } else //Server Cursor { GXLogging.Debug(log, "ExecuteReader: server cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode()); idatareader = new GxMySqlMemoryDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt); } #endif return(idatareader); }
string convertToMySqlCall(string stmt, GxParameterCollection parameters) { if (parameters == null) { return(""); } string pname; StringBuilder sBld = new StringBuilder(); for (int i = 0; i < parameters.Count; i++) { if (i > 0) { sBld.Append(", "); } pname = "@" + parameters[i].ParameterName; sBld.Append(pname); parameters[i].ParameterName = pname; } return("CALL " + stmt + "(" + sBld.ToString() + ")"); }
public GxInformixDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt) : base(connManager, dr, connection, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt) { }
public GxPostgresqlMemoryDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, ushort fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt) : base(connManager, dr, connection, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt) { MemoryDataReader memoryDataReader = new MemoryDataReader(reader, connection, parameters, stmt, fetchSize, forFirst, cached, expiration); Close(); reader = memoryDataReader; }
public GxMySQLDriverCSCursorDataReader(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); cmd.ServerCursor = hasNested; cmd.FetchSize = (uint)fetchSize; 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; } }
public GxMySQLDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt, bool preparedStmts) { 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(); MySQLCommand cmd = (MySQLCommand)dr.GetCommand(con, stmt, parameters); #if !NETCORE cmd.UsePreparedStatement = preparedStmts; #endif 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; } }
public ServiceCommand(IDbConnection conn) { Connection = conn; Parameters = new GxParameterCollection(); }