protected override IDbDataParameter CreateParameter(DBParameter parameter, DbActionOptions options) { var p = new OracleParameter(parameter.Name, parameter.Value); if (!parameter.ParameterType.IsLazy) { p.OracleDbType = GetParameterType(parameter.ParameterType, parameter.Value); } if (parameter.Size != null) { p.Size = parameter.Size.Value; } p.Direction = parameter.ParameterDirection; var opt = options as OracleOptions; switch (p.OracleDbType) { case OracleDbType.Long: case OracleDbType.LongRaw: opt.InitializeLONGFetchSize = -1; break; case OracleDbType.Clob: case OracleDbType.Blob: opt.InitializeLOBFetchSize = -1; break; } return(p); }
protected override void PreQuery(IDbCommand command, DbActionOptions options) { var cmd = (OracleCommand)command; var opt = options as OracleOptions; if (cmd != null && opt != null) { BindOptions(cmd, opt); } base.PreQuery(command, options); }
protected virtual void PreExecute(IDbCommand command, DbActionOptions options) { }
protected virtual void PreQuery(IDbCommand command, DbActionOptions options) { }
protected virtual void BindParameters(IDbCommand command, DBParameterCollection dbParameters, DbActionOptions options) { if (dbParameters != null) { foreach (var dbParameter in dbParameters) { var dbDataParameter = CreateParameter(dbParameter, options); command.Parameters.Add(dbDataParameter); } } }
protected abstract IDbDataParameter CreateParameter(DBParameter parameter, DbActionOptions options);
public virtual DbActionResult <object> ExecuteScalar(string sql, DBParameterCollection dbParameters, DbActionOptions options = null) { var queryParameter = new QueryParameter(sql, dbParameters, options, null); return(ActionWithConnectionHandler(() => { var dynamicParameter = CreateDynamicParameters(dbParameters); return _connection.ExecuteScalar(sql, dynamicParameter, _transaction); }, queryParameter)); }
public virtual DbActionResult <object> ExecuteStoreProcedure(string name, DBParameterCollection dbParameters, DbActionOptions options = null) { var queryParameter = new QueryParameter(name, dbParameters, options, null); return(ActionWithConnectionHandler(() => { using (var cmd = _connection.CreateCommand()) { cmd.CommandText = name; cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = _transaction; BindParameters(cmd, dbParameters, options); PreExecute(cmd, options); cmd.ExecuteNonQuery(); return RestoreParameters(cmd, dbParameters); } }, queryParameter)); }
public virtual DbActionResult <int> ExecuteNonQuery(string sql, DBParameterCollection dbParameters, DbActionOptions options = null) { var queryParameter = new QueryParameter(sql, dbParameters, options, null); return(ActionWithConnectionHandler(() => { Log("QueryTable", sql, dbParameters); using (var cmd = _connection.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Transaction = _transaction; BindParameters(cmd, dbParameters, options); PreExecute(cmd, options); var effectRows = cmd.ExecuteNonQuery(); RestoreParameters(cmd, dbParameters); return effectRows; } }, queryParameter)); }
public virtual DbActionResult <DataTable> QueryFirst(string sql, DBParameterCollection dbParameters, DbActionOptions options = null) { var queryParameter = new QueryParameter(sql, dbParameters, options, null); return(ActionWithConnectionHandler(() => { Log("QueryFirstRow", sql, dbParameters); using (var cmd = _connection.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Transaction = _transaction; BindParameters(cmd, dbParameters, options); PreQuery(cmd, options); return CreateDataTable(cmd, 0, 1); } }, queryParameter)); }
public virtual DbActionResult <object> QueryFirst(string sql, DBParameterCollection dbParameters, Type dataType, DbActionOptions options = null) { var queryParameter = new QueryParameter(sql, dbParameters, options, dataType); return(ActionWithConnectionHandler(() => { Log("QueryFirst", sql, dbParameters); var dynamicParameter = CreateDynamicParameters(dbParameters); var data = _connection.QueryFirstOrDefault(dataType, sql, dynamicParameter, _transaction); return data; }, queryParameter)); }
public virtual DbActionResult <IList> Query(string sql, DBParameterCollection dbParameters, Type dataType, DbActionOptions options = null) { var queryParameter = new QueryParameter(sql, dbParameters, options, dataType); return(ActionWithConnectionHandler(() => { Log("QueryList", sql, dbParameters); var dynamicParameter = CreateDynamicParameters(dbParameters); IList list = _connection.Query(dataType, sql, dynamicParameter, _transaction).ToList(); if (dataType != null) { list = AncestorResultHelper.MakeList(list, dataType); } return list; }, queryParameter)); }
protected override IDbDataParameter CreateParameter(DBParameter parameter, DbActionOptions options) { throw new NotImplementedException(); }