コード例 #1
0
        /// <summary>
        /// 获取DataSet
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pars"></param>
        /// <returns></returns>
        public DataSet GetDataSetAll(string sql, params OracleParameter[] pars)
        {
            OracleConfig.SetParsName(pars);
            sql = OracleConfig.GetOracleSql(sql);
            ExecLogEvent(sql, pars, true);
            OracleDataAdapter _OracleDataAdapter = new OracleDataAdapter(sql, _OracleConnection);

            if (_tran != null)
            {
                _OracleDataAdapter.SelectCommand.Transaction = _tran;
            }
            if (IsGetPageParas)
            {
                SqlSugarToolExtensions.RequestParasToOracleParameters(_OracleDataAdapter.SelectCommand.Parameters);
            }
            _OracleDataAdapter.SelectCommand.CommandTimeout = this.CommandTimeOut;
            _OracleDataAdapter.SelectCommand.CommandType    = CommandType;
            _OracleDataAdapter.SelectCommand.BindByName     = true;
            if (pars != null)
            {
                _OracleDataAdapter.SelectCommand.Parameters.AddRange(pars);
            }
            DataSet ds = new DataSet();

            _OracleDataAdapter.Fill(ds);
            if (IsClearParameters)
            {
                _OracleDataAdapter.SelectCommand.Parameters.Clear();
            }
            ExecLogEvent(sql, pars, false);
            return(ds);
        }
コード例 #2
0
        /// <summary>
        /// 获取DataReader
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pars"></param>
        /// <returns></returns>
        public OracleDataReader GetReader(string sql, params OracleParameter[] pars)
        {
            OracleConfig.SetParsName(pars);
            sql = OracleConfig.GetOracleSql(sql);
            ExecLogEvent(sql, pars, true);
            OracleCommand OracleCommand = new OracleCommand(sql, _OracleConnection);

            OracleCommand.BindByName     = true;
            OracleCommand.CommandType    = CommandType;
            OracleCommand.CommandTimeout = this.CommandTimeOut;
            if (_tran != null)
            {
                OracleCommand.Transaction = _tran;
            }
            if (pars != null)
            {
                OracleCommand.Parameters.AddRange(pars);
            }
            if (IsGetPageParas)
            {
                SqlSugarToolExtensions.RequestParasToOracleParameters(OracleCommand.Parameters);
            }
            OracleDataReader OracleDataReader = OracleCommand.ExecuteReader();

            if (IsClearParameters)
            {
                OracleCommand.Parameters.Clear();
            }
            ExecLogEvent(sql, pars, false);
            return(OracleDataReader);
        }