コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="database"></param>
        /// <returns></returns>
        public IEnumerable<StoredProcedureResultSet> EnumerateResultSets(Database database)
        {
            if (database == null) throw new ArgumentNullException("database");
            DbDataReader dr = null;
            var previousState = database.ConnectionState;

            try
            {
                var resultsets = new List<StoredProcedureResultSet>();
                var cm = CreateCommand();
                dr = database.ExecuteReader(cm);
                while (dr.Read())
                {
                    var rs = CreateResultSets(dr);
                    resultsets.Add(rs);
                    yield return rs;
                }
                dr.Close();
                this.SetOutputParameterValue(cm);
            }
            finally
            {
                if (dr != null) { dr.Dispose(); }
                if (previousState == ConnectionState.Closed && database.ConnectionState == ConnectionState.Open) { database.Close(); }
                if (previousState == ConnectionState.Closed && database.OnTransaction == false) { database.Dispose(); }
            }
        }
コード例 #2
0
ファイル: DatabaseContext.cs プロジェクト: fengweijp/higlabo
 /// <summary>
 /// 
 /// </summary>
 /// <param name="transactionKey"></param>
 /// <param name="isolationLevel"></param>
 public DatabaseContext(Database database, String transactionKey, IsolationLevel isolationLevel)
 {
     this.Initialize(database, transactionKey, isolationLevel);
 }
コード例 #3
0
ファイル: DatabaseContext.cs プロジェクト: fengweijp/higlabo
 /// <summary>
 /// 
 /// </summary>
 /// <param name="transactionKey"></param>
 public DatabaseContext(Database database, String transactionKey)
 {
     this.Initialize(database, transactionKey, null);
 }
コード例 #4
0
ファイル: DatabaseContext.cs プロジェクト: fengweijp/higlabo
 /// <summary>
 /// 
 /// </summary>
 public DatabaseContext(Database database)
 {
     this.Initialize(database, "", null);
 }
コード例 #5
0
ファイル: DatabaseContext.cs プロジェクト: fengweijp/higlabo
 private void Initialize(Database database, String transactionKey, IsolationLevel? isolationLevel)
 {
     this.TransactionKey = transactionKey;
     this.Database = database;
     DatabaseContext.SetDatabaseContext(this.TransactionKey, this);
     if (isolationLevel.HasValue == true)
     {
         this.BeginTransaction(isolationLevel.Value);
     }
 }
コード例 #6
0
 protected override void ExecuteCommand(Database database, string query)
 {
     var db = database as MySqlDatabase;
     var script = new MySqlScript();
     script.Delimiter = "//";
     script.Query = query;
     db.ExecuteCommand(script);
 }
コード例 #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="database"></param>
 /// <returns></returns>
 public DataTable GetDataTable(Database database)
 {
     if (database == null) throw new ArgumentNullException("database");
     var previousState = database.ConnectionState;
     try
     {
         var cm = CreateCommand();
         var dt = database.GetDataTable(cm);
         return dt;
     }
     finally
     {
         if (previousState == ConnectionState.Closed && database.OnTransaction == false) { database.Dispose(); }
     }
 }
コード例 #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="database"></param>
 /// <returns></returns>
 public List<StoredProcedureResultSet> GetResultSets(Database database)
 {
     return EnumerateResultSets(database).ToList();
 }
コード例 #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="database"></param>
 /// <returns></returns>
 public StoredProcedureResultSet GetFirstResultSet(Database database)
 {
     return this.GetResultSets(database).FirstOrDefault();
 }