コード例 #1
0
        /// <summary>
        /// Execute a command against a data source, mapping the data reader GetSchemaTable() result to an enumerable of resultsets, each with an enumerable of records dictionaries.
        /// This method perfoms LAZY LOADING/DEFERRED EXECUTION.
        /// </summary>
        /// <param name="dataReader"> The target data reader. </param>
        /// <returns> An enumerable of resultset instances, each containing an enumerable of dictionaries with record key/value pairs of schema metadata. </returns>
        public IEnumerable <IResultset> GetSchemaResultsetsFromReader(IDataReader dataReader)
        {
            int resultsetIndex = 0;

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): enter", typeof(AdoNetYieldingFascade).Name));

            if ((object)dataReader == null)
            {
                throw new ArgumentNullException("dataReader");
            }

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): before yield", typeof(AdoNetYieldingFascade).Name));

            using (dataReader)
            {
                OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): use reader", typeof(AdoNetYieldingFascade).Name));

                do
                {
                    Resultset resultset = new Resultset(resultsetIndex++);                     // prevent modified closure
                    resultset.Records = this.GetSchemaRecordsFromReader(dataReader, (ra) => resultset.RecordsAffected = ra);

                    OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): on yield", typeof(AdoNetYieldingFascade).Name));

                    yield return(resultset);                    // LAZY PROCESSING INTENT HERE / DO NOT FORCE EAGER LOAD
                }while (dataReader.NextResult());

                OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): dispose reader", typeof(AdoNetYieldingFascade).Name));
            }

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): after yield", typeof(AdoNetYieldingFascade).Name));

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): leave", typeof(AdoNetYieldingFascade).Name));
        }
コード例 #2
0
        /// <summary>
        /// Execute a command against a data source, mapping the data reader GetSchemaTable() result to an enumerable of resultsets, each with an enumerable of records dictionaries.
        /// This method perfoms LAZY LOADING/DEFERRED EXECUTION.
        /// </summary>
        /// <param name="dataReader"> The target data reader. </param>
        /// <returns> An enumerable of resultset instances, each containing an enumerable of dictionaries with record key/value pairs of schema metadata. </returns>
        public IEnumerable<IResultset> GetSchemaResultsetsFromReader(IDataReader dataReader)
        {
            int resultsetIndex = 0;

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): enter", typeof(AdoNetYieldingFascade).Name));

            if ((object)dataReader == null)
                throw new ArgumentNullException("dataReader");

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): before yield", typeof(AdoNetYieldingFascade).Name));

            using (dataReader)
            {
                OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): use reader", typeof(AdoNetYieldingFascade).Name));

                do
                {
                    Resultset resultset = new Resultset(resultsetIndex++); // prevent modified closure
                    resultset.Records = this.GetSchemaRecordsFromReader(dataReader, (ra) => resultset.RecordsAffected = ra);

                    OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): on yield", typeof(AdoNetYieldingFascade).Name));

                    yield return resultset; // LAZY PROCESSING INTENT HERE / DO NOT FORCE EAGER LOAD
                }
                while (dataReader.NextResult());

                OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): dispose reader", typeof(AdoNetYieldingFascade).Name));
            }

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): after yield", typeof(AdoNetYieldingFascade).Name));

            OnlyWhen._PROFILE_ThenPrint(string.Format("{0}::GetSchemaResultsetsFromReader(...): leave", typeof(AdoNetYieldingFascade).Name));
        }