示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 protected virtual void PreExecute(IDbCommand command, DbActionOptions options)
 {
 }
示例#4
0
 protected virtual void PreQuery(IDbCommand command, DbActionOptions options)
 {
 }
示例#5
0
 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);
         }
     }
 }
示例#6
0
 protected abstract IDbDataParameter CreateParameter(DBParameter parameter, DbActionOptions options);
示例#7
0
        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));
        }
示例#8
0
        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));
        }
示例#9
0
        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));
        }
示例#10
0
        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));
        }
示例#11
0
        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));
        }
示例#12
0
        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));
        }
示例#13
0
 protected override IDbDataParameter CreateParameter(DBParameter parameter, DbActionOptions options)
 {
     throw new NotImplementedException();
 }