Oracle数据库操作类及连接方法

创建DataBaseAccess引用库下面包括DBConnectionString.cs,DBType.cs ,SysName.cs 三个类

DBConnectionString:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace DataBaseAccess

{

    /// <summary>

    /// 数据库类型访问连接

    /// </summary>

    public class DBConnectionString

    {

        public static DBType GetDbType()

        {

            return DBType.Oracle;

        }



        public static string getConnString(SysName sysname)

        {

            if (GetDbType() == DBType.Oracle)

            {

                switch (sysname)

                {

                    case SysName.TESTDB:

                        return "Data Source=TESTDB;Persist Security Info=True;User ID=scott;Password=tiger;Unicode=True";

                    case SysName.CMS:

                        return "Data Source=服务器数据库名;Persist Security Info=True;User ID=CMS;Password=CMS;Unicode=True";

                    case SysName.ERP:

                        return "Data Source=服务器数据库名;Persist Security Info=True;User ID=ERP;Password=ERP;Unicode=True";

                    case SysName.ORCL:

                        return "Data Source=orcl;Persist Security Info=True;User ID=ORCL;Password=123;Unicode=True";

                   

                }

                return string.Empty;

            }

            return string.Empty;

        }

    }

}
View Code

DBType:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace DataBaseAccess

{

    /// <summary>

    /// 数据库类型枚举

    /// </summary>

   public enum DBType

    {

        Oracle = 0,

        Access = 1,

       Sqlserver=2

    }

}

SysName:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace DataBaseAccess

{

    

    /// <summary>

    /// 访问系统对应数据库名称

    /// </summary>

    public enum SysName

    {

        TESTDB=1,

        CMS=2,

        ERP=3,

        ORCL=4

    }

}
View Code

DataSys-Common文件夹下包括DBHelper.cs,OracleHelper.cs,QueryParam.cs

DBHelper:

using System;

using System.Collections.Generic;

using System.Data.Common;

using System.Linq;

using System.Web;

using DataBaseAccess;

using System.Data.OracleClient;

namespace LoginWebApp.Common

{

     //abstract 抽象类 修饰符指示所修饰的内容缺少实现或未完全实现。 

    //abstract 修饰符可用于类、方法、属性、索引器和事件。 

    //在类声明中使用 abstract 修饰符以指示某个类只能是其他类的基类。

    //标记为抽象或包含在抽象类中的成员必须通过从抽象类派生的类来实现。



    public abstract class DBHelper

    {

        public static DbConnection GetDbConnection(SysName dbname)

        {

            return new OracleConnection(DBConnectionString.getConnString(dbname));

        }

    }

}
View Code

OracleHelper:

using DataBaseAccess;

using System;

using System.Collections;

using System.Collections.Generic;

using System.Data;

using System.Data.OracleClient;

using System.IO;

using System.Linq;

using System.Text;

using System.Web;



namespace LoginWebApp.Common

{

    /// <summary>

    //abstract 抽象类 修饰符指示所修饰的内容缺少实现或未完全实现。 

    //abstract 修饰符可用于类、方法、属性、索引器和事件。 

    //在类声明中使用 abstract 修饰符以指示某个类只能是其他类的基类。

    //标记为抽象或包含在抽象类中的成员必须通过从抽象类派生的类来实现。

    /// A helper class used to execute queries against an Oracle database

    /// </summary>

    public abstract class OracleHelper

    {

        //Create a hashtable for the parameter cached

        private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());



        /// <summary>

        /// 返回DataTable,如果无commandParameters参数,可传入null

        /// </summary>

        /// <param name="cmdType"></param>

        /// <param name="cmdText"></param>

        /// <param name="commandParameters"></param>

        /// <returns></returns>

        public static DataTable ExecuteDataTable(CommandType cmdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            DataTable dt = new DataTable();

            OracleCommand cmd = new OracleCommand();

            using (OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname)))

            {

                PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);

                OracleDataAdapter da = new OracleDataAdapter(cmd);

                da.Fill(dt);

                cmd.Parameters.Clear();

                cmd.Dispose();

                return dt;

            }



        }



        /// <summary>  

        /// 执行数据库查询操作,返回DataSet类型的结果集  

        /// </summary>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作返回的DataSet类型的结果集</returns> 

        public static DataSet ExecuteDataSet(CommandType cmdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            DataSet ds = new DataSet();

            OracleCommand cmd = new OracleCommand();

            using (OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname)))

            {

                try

                {

                    PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);

                    OracleDataAdapter da = new OracleDataAdapter(cmd);

                    da.Fill(ds);

                    cmd.Parameters.Clear();



                }

                catch

                {

                    throw;

                }

                finally

                {

                    cmd.Dispose();

                    connection.Close();

                    connection.Dispose();



                }

            }

            return ds;

        }



        /// <summary>

        /// 公用查询方法,分页查询数据

        /// </summary>

        /// <param name="qp"></param>

        /// <param name="recordCount"></param>

        /// <returns></returns>

        public static DataTable ExecuteDataTable(QueryParam qp, out int recordCount, SysName sysname)

        {

            DataTable dt = new DataTable();

            using (OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname)))

            {

                StringBuilder sb = new StringBuilder();

                int TotalRecordForPageIndex = qp.PageIndex * qp.PageSize;

                int FirstRecordForPageIndex = (qp.PageIndex - 1) * qp.PageSize;

                string OrderBy;

                if (qp.OrderType == 1)

                {

                    OrderBy = " Order by " + qp.Orderfld.Replace(",", " desc,") + " desc ";

                }

                else

                {

                    OrderBy = " Order by " + qp.Orderfld.Replace(",", " asc,") + " asc ";

                }

                sb.AppendFormat("SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT * FROM {0} {1} {2}) A WHERE ROWNUM <= {3})WHERE RN > {4} ", qp.TableName.ToUpper(), qp.Where, OrderBy, TotalRecordForPageIndex, FirstRecordForPageIndex);

                OracleCommand cmd = new OracleCommand(sb.ToString(), connection);

                OracleDataAdapter da = new OracleDataAdapter(cmd);

                da.Fill(dt);

                connection.Open();

                cmd.Dispose();

                cmd = new OracleCommand();

                cmd.Connection = connection;

                cmd.CommandText = string.Format("SELECT Count(1) From {0} {1}", qp.TableName, qp.Where);

                recordCount = Convert.ToInt32(cmd.ExecuteScalar());

                cmd.Dispose();

                return dt;

            }

        }

        /// <summary>  

        /// 执行数据库查询操作,返回DataTable类型的结果集  

        /// </summary>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作返回的DataTable类型的结果集</returns>  

        internal static DataTable ExecuteDataTable(string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            OracleCommand command = new OracleCommand();

            OracleConnection connection = new OracleConnection((DBConnectionString.getConnString(sysname)));

            DataTable table = null;



            try

            {

                PrepareCommand(command, connection, null, CommandType.Text, cmdText, commandParameters);

                OracleDataAdapter adapter = new OracleDataAdapter();

                adapter.SelectCommand = command;

                table = new DataTable();

                adapter.Fill(table);

                command.Parameters.Clear();

            }

            catch

            {

                throw;

            }

            finally

            {

                command.Dispose();

                connection.Close();

                connection.Dispose();

            }



            return table;

        }

        /// <summary>  

        /// 执行数据库查询操作,返回结果集中位于第一行第一列的Object类型的值  

        /// </summary>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作返回的结果集中位于第一行第一列的Object类型的值</returns>

        public static object ExecuteScalar(CommandType cmdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            OracleCommand cmd = new OracleCommand();

            object result = null;

            using (OracleConnection conn = new OracleConnection(DBConnectionString.getConnString(sysname)))

            {

                try

                {

                    PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);

                    result = cmd.ExecuteScalar();

                    cmd.Parameters.Clear();





                }

                catch

                {

                    throw;

                }

                finally

                {

                    cmd.Dispose();

                    conn.Dispose();

                    conn.Close();

                }

            }

            return result;

        }

        ///    <summary>  

        ///    执行数据库事务查询操作,返回结果集中位于第一行第一列的Object类型的值  

        ///    </summary>  

        ///    <param name="transaction">一个已存在的数据库事务对象</param>  

        ///    <param name="commandType">命令类型</param>  

        ///    <param name="commandText">Oracle存储过程名称或PL/SQL命令</param>  

        ///    <param name="commandParameters">命令参数集合</param>  

        ///    <returns>当前事务查询操作返回的结果集中位于第一行第一列的Object类型的值</returns> 

        public static object ExecuteScalar(OracleTransaction transaction, CommandType cmdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            if (transaction == null)

                throw new ArgumentNullException("当前数据库事务不存在");

            OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname));

            connection = transaction.Connection; //打开连接事物

            if (transaction != null && transaction.Connection == null)

                throw new ArgumentException("当前事务所在的数据库连接不存在");



            // Create a    command    and    prepare    it for execution

            OracleCommand cmd = new OracleCommand();

            object result = null;

            try

            {

                PrepareCommand(cmd, transaction.Connection, transaction, cmdType, cmdText, commandParameters);



                // Execute the command & return    the    results

                result = cmd.ExecuteScalar();



                // Detach the SqlParameters    from the command object, so    they can be    used again

                cmd.Parameters.Clear();





            }

            catch

            {

                throw;

            }

            finally

            {

                transaction.Dispose();

                cmd.Dispose();

                transaction.Connection.Dispose();

                transaction.Connection.Close();

            }

            return result;

        }

        /// <summary>  

        /// 执行数据库查询操作,返回结果集中位于第一行第一列的Object类型的值  

        /// </summary>  

        /// <param name="connection">数据库连接对象</param>  

        /// <param name="cmdType">Command类型</param>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作返回的结果集中位于第一行第一列的Object类型的值</returns>  

        internal static object ExecuteScalar(SysName sysname, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters)

        {

            OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname));

            if (connection == null) throw new ArgumentException("当前数据库连接不存在");

            OracleCommand command = new OracleCommand();

            object result = null;



            try

            {

                PrepareCommand(command, connection, null, cmdType, cmdText, commandParameters);

                result = command.ExecuteScalar();

                command.Parameters.Clear();

            }

            catch

            {

                throw;

            }

            finally

            {

                command.Dispose();

                connection.Close();

                connection.Dispose();

            }



            return result;

        }



        /// <summary>  

        /// 执行数据库查询操作,返回受影响的行数  

        /// </summary>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作影响的数据行数</returns> 

        public static int ExecuteNonQuery(CommandType commdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            // Create a new Oracle command

            OracleCommand cmd = new OracleCommand();

            int result = 0;

            //Create a connection

            using (OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname)))

            {

                try

                {

                    //Prepare the command

                    PrepareCommand(cmd, connection, null, commdType, cmdText, commandParameters);



                    //Execute the command

                    result = cmd.ExecuteNonQuery();

                    cmd.Parameters.Clear();

                }

                catch

                {

                    throw;

                }

                finally

                {

                    cmd.Dispose();

                    connection.Dispose();

                    connection.Close();

                }

            }

            return result;

        }

        /// <summary>  

        /// 执行数据库查询操作,返回受影响的行数  

        /// </summary>  

        /// <param name="connection">Oracle数据库连接对象</param>  

        /// <param name="cmdType">Command类型</param>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作影响的数据行数</returns>  

        internal static int ExecuteNonQuery(SysName sysname, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters)

        {

            OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname));

            if (connection == null) throw new ArgumentNullException("当前数据库连接不存在");

            OracleCommand command = new OracleCommand();

            int result = 0;



            try

            {

                PrepareCommand(command, connection, null, cmdType, cmdText, commandParameters);

                result = command.ExecuteNonQuery();

                command.Parameters.Clear();

            }

            catch

            {

                throw;

            }

            finally

            {

                command.Dispose();

                connection.Close();

                connection.Dispose();

            }



            return result;

        }



        /// <summary>  

        /// 执行数据库事务查询操作,返回受影响的行数  

        /// </summary>  

        /// <param name="trans">数据库事务对象</param>  

        /// <param name="cmdType">Command类型</param>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前事务查询操作影响的数据行数</returns> 

        public static int ExecuteNonQuery(OracleTransaction trans, CommandType cmdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {

            OracleCommand cmd = new OracleCommand();

            int result = 0;

            try

            {

                //执行事务 连接事物

                PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);

                result = cmd.ExecuteNonQuery();

                cmd.Parameters.Clear();

            }

            catch

            {

                throw;

            }

            finally

            {

                trans.Dispose();

                cmd.Dispose();

                trans.Connection.Close();

                trans.Connection.Dispose();



            }

            return result;

        }







        /// <summary>  

        /// 执行数据库查询操作,返回OracleDataReader类型的内存结果集  

        /// </summary>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param>  

        /// <returns>当前查询操作返回的OracleDataReader类型的内存结果集</returns>

        public static OracleDataReader ExecuteReader(CommandType cmdType, string cmdText, SysName sysname, params OracleParameter[] commandParameters)

        {



            //Create the command and connection

            OracleCommand cmd = new OracleCommand();

            OracleConnection conn = new OracleConnection(DBConnectionString.getConnString(sysname));

            OracleDataReader reader = null;

            try

            {

                //Prepare the command to execute

                PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);



                //Execute the query, stating that the connection should close when the resulting datareader has been read

                reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                cmd.Parameters.Clear();

                return reader;



            }

            catch

            {



                //If an error occurs close the connection as the reader will not be used and we expect it to close the connection

                cmd.Dispose();

                conn.Close();

                throw;

            }

        }





        /// <summary>

        /// Add a set of parameters to the cached

        /// </summary>

        /// <param name="cacheKey">Key value to look up the parameters</param>

        /// <param name="commandParameters">Actual parameters to cached</param>

        public static void CacheParameters(string cacheKey, params OracleParameter[] commandParameters)

        {

            parmCache[cacheKey] = commandParameters;

        }



        /// <summary>

        /// Fetch parameters from the cache

        /// </summary>

        /// <param name="cacheKey">Key to look up the parameters</param>

        /// <returns></returns>

        public static OracleParameter[] GetCachedParameters(string cacheKey)

        {

            OracleParameter[] cachedParms = (OracleParameter[])parmCache[cacheKey];



            if (cachedParms == null)

                return null;



            // If the parameters are in the cache

            OracleParameter[] clonedParms = new OracleParameter[cachedParms.Length];



            // return a copy of the parameters

            for (int i = 0, j = cachedParms.Length; i < j; i++)

                clonedParms[i] = (OracleParameter)((ICloneable)cachedParms[i]).Clone();



            return clonedParms;

        }



        /// <summary>  

        /// 执行数据库命令前的准备工作  

        /// </summary>  

        /// <param name="command">Command对象</param>  

        /// <param name="connection">数据库连接对象</param>  

        /// <param name="trans">事务对象</param>  

        /// <param name="cmdType">Command类型</param>  

        /// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>  

        /// <param name="commandParameters">命令参数集合</param> 

        private static void PrepareCommand(OracleCommand cmd, OracleConnection conn, OracleTransaction trans, CommandType cmdType, string cmdText, OracleParameter[] commandParameters)

        {



            //Open the connection if required

            if (conn.State != ConnectionState.Open)

                conn.Open();



            //Set up the command

            cmd.Connection = conn;

            cmd.CommandText = cmdText;

            cmd.CommandType = cmdType;



            //Bind it to the transaction if it exists

            if (trans != null)

                cmd.Transaction = trans;



            // Bind the parameters passed in

            if (commandParameters != null)

            {

                foreach (OracleParameter parm in commandParameters)

                    cmd.Parameters.Add(parm);

            }

        }



        /// <summary>

        /// Converter to use boolean data type with Oracle

        /// </summary>

        /// <param name="value">Value to convert</param>

        /// <returns></returns>

        public static string OraBit(bool value)

        {

            if (value)

                return "Y";

            else

                return "N";

        }



        /// <summary>

        /// Converter to use boolean data type with Oracle

        /// </summary>

        /// <param name="value">Value to convert</param>

        /// <returns></returns>

        public static bool OraBool(string value)

        {

            if (value.Equals("Y"))

                return true;

            else

                return false;

        }



        /// <summary>  

        /// 将.NET日期时间类型转化为Oracle兼容的日期时间格式字符串  

        /// </summary>  

        /// <param name="date">.NET日期时间类型对象</param>  

        /// <returns>Oracle兼容的日期时间格式字符串(如该字符串:TO_DATE('2014-04-10','YYYY-MM-DD'))</returns>  

        internal static string GetOracleDateFormat(DateTime date)

        {

            return "TO_DATE('" + date.ToString("yyyy-M-dd") + "','YYYY-MM-DD')";

        }



        /// <summary>  

        /// 将.NET日期时间类型转化为Oracle兼容的日期格式字符串  

        /// </summary>  

        /// <param name="date">.NET日期时间类型对象</param>  

        /// <param name="format">Oracle日期时间类型格式化限定符</param>  

        /// <returns>Oracle兼容的日期时间格式字符串(如该字符串:TO_DATE('2014-04-10','YYYY-MM-DD'))</returns>  

        internal static string GetOracleDateFormat(DateTime date, string format)

        {

            if (format == null || format.Trim() == "") format = "YYYY-MM-DD";

            return "TO_DATE('" + date.ToString("yyyy-M-dd") + "','" + format + "')";

        }



        /// <summary>  

        /// 将指定的关键字处理为模糊查询时的合法参数值  

        /// </summary>  

        /// <param name="source">待处理的查询关键字</param>  

        /// <returns>过滤后的查询关键字</returns>  

        internal static string HandleLikeKey(string source)

        {

            if (source == null || source.Trim() == "") return null;



            source = source.Replace("[", "[]]");

            source = source.Replace("_", "[_]");

            source = source.Replace("%", "[%]");



            return ("%" + source + "%");

        }



        /// <summary>  

        /// 将文本内容写入到数据库的CLOB字段中(不可用:报连接被关闭的异常)  

        /// </summary>  

        /// <param name="connectionString">数据库连接字符串</param>  

        /// <param name="table">数据库表名称</param>  

        /// <param name="where">指定的WHERE条件语句</param>  

        /// <param name="clobField">CLOB字段的名称</param>  

        /// <param name="content">要写入的文本内容</param>  

        internal static void WriteCLOB(string table, string where, string clobField, SysName sysname, string content)

        {

            if (String.IsNullOrEmpty(DBConnectionString.getConnString(sysname)) || String.IsNullOrEmpty(table) || String.IsNullOrEmpty(clobField)) return;



            using (OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(sysname)))

            {

                OracleCommand command = null;



                try

                {

                    connection.Open();

                    command = connection.CreateCommand();

                    command.CommandText = "SELECT " + clobField + " FROM " + table + " WHERE " + where + " FOR UPDATE";

                    OracleDataReader reader = command.ExecuteReader();



                    if (reader != null && reader.HasRows)

                    {

                        reader.Read();

                        command.Transaction = command.Connection.BeginTransaction();



                        OracleLob lob = reader.GetOracleLob(0);

                        byte[] buffer = Encoding.Unicode.GetBytes(content);

                        if (lob != OracleLob.Null) lob.Erase();

                        lob.Write(buffer, 0, ((buffer.Length % 2 == 0) ? buffer.Length : (buffer.Length - 1)));



                        command.Transaction.Commit();

                        reader.Close();

                    }

                }

                catch

                {

                    command.Transaction.Rollback();

                    throw;

                }

                finally

                {

                    command.Dispose();

                    connection.Close();

                    connection.Dispose();

                }

            }

        }



        /// <summary>  

        /// 从数据库中读取CLOB字段的内容并进行输出  

        /// </summary>  

        /// <param name="connectionString">数据库连接字符串</param>  

        /// <param name="table">数据库表名称</param>  

        /// <param name="where">指定的WHERE条件语句</param>  

        /// <param name="clobField">CLOB字段的名称</param>  

        /// <param name="output">保存内容输出的字符串变量</param>  

        internal static void ReadCLOB(SysName dbname, string table, string where, string clobField, ref string output)

        {

            if (String.IsNullOrEmpty(DBConnectionString.getConnString(dbname)) || String.IsNullOrEmpty(table) || String.IsNullOrEmpty(clobField)) return;



            using (OracleConnection connection = new OracleConnection(DBConnectionString.getConnString(dbname)))

            {

                OracleCommand command = null;

                StreamReader stream = null;



                try

                {

                    connection.Open();

                    command = connection.CreateCommand();

                    command.CommandText = "SELECT " + clobField + " FROM " + table + " WHERE " + where;

                    OracleDataReader reader = command.ExecuteReader();



                    if (reader != null && reader.HasRows)

                    {

                        reader.Read();

                        command.Transaction = command.Connection.BeginTransaction();



                        OracleLob lob = reader.GetOracleLob(0);

                        if (lob != OracleLob.Null)

                        {

                            stream = new StreamReader(lob, Encoding.Unicode);

                            output = stream.ReadToEnd().Trim();

                            command.Transaction.Commit();

                            reader.Close();

                        }

                    }

                }

                catch

                {

                    command.Transaction.Rollback();

                    throw;

                }

                finally

                {

                    stream.Close();

                    command.Dispose();

                    connection.Close();

                    connection.Dispose();

                }

            }

        }

    }

}
View Code

QueryParam:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;



namespace LoginWebApp.Common

{

    /// <summary>

    /// 分页存储过程查询参数类

    /// </summary>

    public class QueryParam

    {



        /// <summary>

        /// 构造函数

        /// </summary>

        public QueryParam()

            : this(1, int.MaxValue)

        { }



        /// <summary>

        /// 构造函数

        /// </summary>

        /// <param name="_mPageIndex">当前页码</param>

        /// <param name="_mPageSize">每页记录数</param>

        public QueryParam(int _mPageIndex, int _mPageSize)

        {

            _PageIndex = _mPageIndex;

            _PageSize = _mPageSize;

        }



        /// <summary>

        /// 构造函数

        /// </summary>

        /// <param name="_mOrderType">排序类型 1:降序 其它为升序</param>

        /// <param name="_mPageIndex">当前页码</param>

        /// <param name="_mPageSize">每页记录数</param>

        public QueryParam(int _mOrderType, int _mPageIndex, int _mPageSize)

        {

            _OrderType = _mOrderType;

            _PageIndex = _mPageIndex;

            _PageSize = _mPageSize;

        }



        /// <summary>

        /// 构造函数

        /// </summary>

        /// <param name="_mWhere">查询条件 需带Where</param>

        /// <param name="_mOrderType">排序类型 1:降序 其它为升序</param>

        /// <param name="_mPageIndex">当前页码</param>

        /// <param name="_mPageSize">每页记录数</param>

        public QueryParam(string _mWhere, int _mOrderType,

            int _mPageIndex, int _mPageSize)

        {

            _Where = _mWhere;

            _OrderType = _mOrderType;

            _PageIndex = _mPageIndex;

            _PageSize = _mPageSize;

        }



        /// <summary>

        /// 构造函数

        /// </summary>

        /// <param name="_mWhere">查询条件 需带Where</param>

        /// <param name="_mOrderfld">排序字段</param>

        /// <param name="_mOrderType">排序类型 1:降序 其它为升序</param>

        /// <param name="_mPageIndex">当前页码</param>

        /// <param name="_mPageSize">每页记录数</param>

        public QueryParam(string _mWhere, string _mOrderfld, int _mOrderType,

            int _mPageIndex, int _mPageSize)

        {

            _Where = _mWhere;

            _Orderfld = _mOrderfld;

            _OrderType = _mOrderType;

            _PageIndex = _mPageIndex;

            _PageSize = _mPageSize;

        }







        /// <summary>

        /// 构造函数

        /// </summary>

        /// <param name="_mTableName">表名</param>

        /// <param name="_mReturnFields">返回字段</param>

        /// <param name="_mWhere">查询条件 需带Where</param>

        /// <param name="_mOrderfld">排序字段</param>

        /// <param name="_mOrderType">排序类型 1:降序 其它为升序</param>

        /// <param name="_mPageIndex">当前页码</param>

        /// <param name="_mPageSize">每页记录数</param>

        public QueryParam(string _mTableName, string _mReturnFields,

            string _mWhere, string _mOrderfld,

            int _mOrderType, int _mPageIndex, int _mPageSize)

        {

            _TableName = _mTableName;

            _ReturnFields = _mReturnFields;

            _Where = _mWhere;

            _Orderfld = _mOrderfld;

            _OrderType = _mOrderType;

            _PageIndex = _mPageIndex;

            _PageSize = _mPageSize;

        }







        #region "Private Variables"

        private string _TableName;

        private string _ReturnFields;

        private string _Where;

        private string _Orderfld;

        private int _OrderType = 1;

        private int _PageIndex = 1;

        private int _PageSize = int.MaxValue;

        #endregion



        #region "Public Variables"



        /// <summary>

        /// 表名

        /// </summary>

        public string TableName

        {

            get

            {

                return _TableName;

            }

            set

            {

                _TableName = value;

            }



        }







        /// <summary>

        /// 返回字段

        /// </summary>

        public string ReturnFields

        {

            get

            {

                return _ReturnFields;

            }

            set

            {

                _ReturnFields = value;

            }

        }









        /// <summary>

        /// 查询条件 需带Where

        /// </summary>

        public string Where

        {

            get

            {

                return _Where;

            }

            set

            {

                _Where = value;

            }

        }











        /// <summary>

        /// 排序字段

        /// </summary>

        public string Orderfld

        {

            get

            {

                return _Orderfld;

            }

            set

            {

                _Orderfld = value;

            }

        }





        /// <summary>

        /// 排序类型 1:降序 其它为升序

        /// </summary>

        public int OrderType

        {

            get

            {

                return _OrderType;

            }

            set

            {

                _OrderType = value;

            }

        }





        /// <summary>

        /// 当前页码

        /// </summary>

        public int PageIndex

        {

            get

            {

                return _PageIndex;

            }

            set

            {

                _PageIndex = value;

            }



        }





        /// <summary>

        /// 每页记录数

        /// </summary>

        public int PageSize

        {

            get

            {

                return _PageSize;

            }

            set

            {

                _PageSize = value;

            }

        }

        #endregion

    }

}
View Code

DataSys_分别存有不同系统名称连接对应的数据库操作类假如有几个系统分别是CMS、ERP、GPRS等 对应的数据库操作方法类比如GPRS对应下有GPRS_BLLFacade 也就是数据业务逻辑层 GPRS_DataProvider 以及GPRS_OracleDataProvider数据库操作类待续。。。

 

你可能感兴趣的:(oracle数据库)