private static OracleBatchResult <T> ExecuteBatchScript <T>(string connString, IEnumerable <OracleSingleScript> listScript, bool isSelectDataSet, Action <OracleCommand> cmdAction, Func <OracleDataReader, T> funcReader) where T : new()
 {
     using (OracleConnection conn = new OracleConnection(connString))
     {
         TryOpenSqlConnection(conn);
         using (OracleTransaction tran = conn.BeginTransaction())
         {
             OracleBatchResult <T> result = ExecuteBatchScript(conn, tran, listScript, isSelectDataSet, cmdAction, funcReader);
             return(result);
         }
     }
 }
        public static T ExecuteReaderEntity <T>(OracleConnection conn, OracleTransaction tran, string cmdText, Action <OracleCommand> cmdAction, Func <OracleDataReader, T> funcReader) where T : new()
        {
            List <OracleSingleScript> listScript = SplitOracleScript(cmdText);

            if (listScript == null || listScript.Count <= 0 || listScript.Count == 1)
            {
                return(SingleExecuteReaderEntity <T>(conn, tran, cmdText, cmdAction, funcReader));
            }
            else
            {
                OracleBatchResult <T> result = ExecuteBatchScript <T>(conn, tran, listScript, false, cmdAction, funcReader);
                return(result.ExecuteReaderEntity());
            }
        }
        public static object ExecuteScalar(OracleConnection conn, OracleTransaction tran, string cmdText, Action <OracleCommand> cmdAction)
        {
            List <OracleSingleScript> listScript = SplitOracleScript(cmdText);

            if (listScript == null || listScript.Count <= 0 || listScript.Count == 1)
            {
                return(SingleExecuteScalar(conn, tran, cmdText, cmdAction));
            }
            else
            {
                OracleBatchResult <object> result = ExecuteBatchScript <object>(conn, tran, listScript, false, cmdAction, null);
                return(result.ExecuteScalar());
            }
        }
        public static DataSet ExecuteFillDataSet(OracleConnection conn, OracleTransaction tran, string cmdText, Action <OracleCommand> cmdAction)
        {
            List <OracleSingleScript> listScript = SplitOracleScript(cmdText);

            if (listScript == null || listScript.Count <= 0 || listScript.Count == 1)
            {
                DataTable dataTable = SingleExecuteFillDataTable(conn, tran, cmdText, cmdAction);
                DataSet   dataSet   = new DataSet();
                if (dataTable != null)
                {
                    dataSet.Tables.Add(dataTable);
                }
                return(dataSet);
            }
            else
            {
                OracleBatchResult <object> result = ExecuteBatchScript <object>(conn, tran, listScript, true, cmdAction, null);
                return(result.ExecuteFillDataSet());
            }
        }
        private static OracleBatchResult <T> ExecuteBatchScript <T>(OracleConnection conn, OracleTransaction tran, IEnumerable <OracleSingleScript> listScript, bool isSelectDataSet, Action <OracleCommand> cmdAction, Func <OracleDataReader, T> funcReader) where T : new()
        {
            OracleBatchResult <T> result = new OracleBatchResult <T>();

            bool tranIsNull = tran == null;

            if (tranIsNull)
            {
                tran = conn.BeginTransaction();
            }
            try
            {
                foreach (OracleSingleScript script in listScript)
                {
                    #region  执行查询实体

                    if (script.IsSelect)
                    {
                        if (isSelectDataSet)
                        {
                            DataTable dataTable = SingleExecuteFillDataTable(conn, tran, script.SqlScript, cmdAction);
                            result.AddDataTable(dataTable);
                        }
                        else if (typeof(T) == typeof(object) && funcReader == null)
                        {
                            object scalar = SingleExecuteScalar(conn, tran, script.SqlScript, cmdAction);
                            result.AddScalar(scalar);
                        }
                        else
                        {
                            List <T> list = SingleExecuteReaderList <T>(conn, tran, script.SqlScript, cmdAction, funcReader);
                            result.AddList(list);
                        }
                    }

                    #endregion
                    #region  执行增加修改删除

                    if (script.IsInsert || script.IsUpdate || script.IsDelete)
                    {
                        int effect = SingleExecuteNonQuery(conn, tran, script.SqlScript, cmdAction);
                        result.AddEffect(effect);
                    }

                    #endregion
                }
                if (tranIsNull && tran != null)
                {
                    tran.Commit();
                }
            }
            finally
            {
                if (tranIsNull && tran != null)
                {
                    tran.Dispose();
                }
            }

            return(result);
        }