コード例 #1
0
ファイル: DataAdapter.cs プロジェクト: pgovind/runtime
        internal object FillSchemaFromReader(DataSet dataset, DataTable datatable, SchemaType schemaType, string srcTable, IDataReader dataReader)
        {
            DataTable[] dataTables  = null;
            int         schemaCount = 0;

            do
            {
                DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes);

                AssertReaderHandleFieldCount(readerHandler);
                if (0 >= readerHandler.FieldCount)
                {
                    continue;
                }
                string tmp = null;
                if (null != dataset)
                {
                    tmp = DataAdapter.GetSourceTableName(srcTable, schemaCount);
                    schemaCount++; // don't increment if no SchemaTable ( a non-row returning result )
                }

                SchemaMapping mapping = new SchemaMapping(this, dataset, datatable, readerHandler, true, schemaType, tmp, false, null, null);

                if (null != datatable)
                {
                    // do not read remaining results in single DataTable case
                    return(mapping.DataTable);
                }
                else if (null != mapping.DataTable)
                {
                    if (null == dataTables)
                    {
                        dataTables = new DataTable[1] {
                            mapping.DataTable
                        };
                    }
                    else
                    {
                        dataTables = DataAdapter.AddDataTableToArray(dataTables, mapping.DataTable);
                    }
                }
            } while (dataReader.NextResult()); // FillSchema does not capture errors for FillError event

            object value = dataTables;

            if ((null == value) && (null == datatable))
            {
                value = Array.Empty <DataTable>();
            }
            return(value); // null if datatable had no results
        }
コード例 #2
0
        internal object FillSchemaFromReader(DataSet dataset, DataTable datatable, SchemaType schemaType, string srcTable, IDataReader dataReader)
        {
            DataTable[] tables = null;
            int         index  = 0;

            do
            {
                DataReaderContainer container = DataReaderContainer.Create(dataReader, this.ReturnProviderSpecificTypes);
                if (0 < container.FieldCount)
                {
                    string sourceTableName = null;
                    if (dataset != null)
                    {
                        sourceTableName = GetSourceTableName(srcTable, index);
                        index++;
                    }
                    SchemaMapping mapping = new SchemaMapping(this, dataset, datatable, container, true, schemaType, sourceTableName, false, null, null);
                    if (datatable != null)
                    {
                        return(mapping.DataTable);
                    }
                    if (mapping.DataTable != null)
                    {
                        if (tables == null)
                        {
                            tables = new DataTable[] { mapping.DataTable };
                        }
                        else
                        {
                            tables = AddDataTableToArray(tables, mapping.DataTable);
                        }
                    }
                }
            }while (dataReader.NextResult());
            object obj2 = tables;

            if ((obj2 == null) && (datatable == null))
            {
                obj2 = new DataTable[0];
            }
            return(obj2);
        }
コード例 #3
0
        protected virtual int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
        {
            int    num;
            IntPtr ptr;

            Bid.ScopeEnter(out ptr, "<comm.DataAdapter.Fill|API> %d#, dataSet, srcTable, dataReader, startRecord, maxRecords\n", this.ObjectID);
            try
            {
                if (dataSet == null)
                {
                    throw ADP.FillRequires("dataSet");
                }
                if (ADP.IsEmpty(srcTable))
                {
                    throw ADP.FillRequiresSourceTableName("srcTable");
                }
                if (dataReader == null)
                {
                    throw ADP.FillRequires("dataReader");
                }
                if (startRecord < 0)
                {
                    throw ADP.InvalidStartRecord("startRecord", startRecord);
                }
                if (maxRecords < 0)
                {
                    throw ADP.InvalidMaxRecords("maxRecords", maxRecords);
                }
                if (dataReader.IsClosed)
                {
                    return(0);
                }
                DataReaderContainer container = DataReaderContainer.Create(dataReader, this.ReturnProviderSpecificTypes);
                num = this.FillFromReader(dataSet, null, srcTable, container, startRecord, maxRecords, null, null);
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(num);
        }
コード例 #4
0
ファイル: DataAdapter.cs プロジェクト: pgovind/runtime
        protected virtual int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DataAdapter.Fill|API> {0}, dataSet, srcTable, dataReader, startRecord, maxRecords", ObjectID);

            try
            {
                if (null == dataSet)
                {
                    throw ADP.FillRequires(nameof(dataSet));
                }
                if (string.IsNullOrEmpty(srcTable))
                {
                    throw ADP.FillRequiresSourceTableName(nameof(srcTable));
                }
                if (null == dataReader)
                {
                    throw ADP.FillRequires(nameof(dataReader));
                }
                if (startRecord < 0)
                {
                    throw ADP.InvalidStartRecord(nameof(startRecord), startRecord);
                }
                if (maxRecords < 0)
                {
                    throw ADP.InvalidMaxRecords(nameof(maxRecords), maxRecords);
                }
                if (dataReader.IsClosed)
                {
                    return(0);
                }
                // user must Close/Dispose of the dataReader
                DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes);
                return(FillFromReader(dataSet, null, srcTable, readerHandler, startRecord, maxRecords, null, null));
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }
コード例 #5
0
ファイル: DataAdapter.cs プロジェクト: dox0/DotNet471RS3
        virtual protected int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)   // V1.2.3300, DbDataAdapter V1.0.3300
        {
            IntPtr hscp;

            Bid.ScopeEnter(out hscp, "<comm.DataAdapter.Fill|API> %d#, dataSet, srcTable, dataReader, startRecord, maxRecords\n", ObjectID);
            try {
                if (null == dataSet)
                {
                    throw ADP.FillRequires("dataSet");
                }
                if (ADP.IsEmpty(srcTable))
                {
                    throw ADP.FillRequiresSourceTableName("srcTable");
                }
                if (null == dataReader)
                {
                    throw ADP.FillRequires("dataReader");
                }
                if (startRecord < 0)
                {
                    throw ADP.InvalidStartRecord("startRecord", startRecord);
                }
                if (maxRecords < 0)
                {
                    throw ADP.InvalidMaxRecords("maxRecords", maxRecords);
                }
                if (dataReader.IsClosed)
                {
                    return(0);
                }
                // user must Close/Dispose of the dataReader
                DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes);
                return(FillFromReader(dataSet, null, srcTable, readerHandler, startRecord, maxRecords, null, null));
            }
            finally {
                Bid.ScopeLeave(ref hscp);
            }
        }
コード例 #6
0
ファイル: DataAdapter.cs プロジェクト: pgovind/runtime
        protected virtual int Fill(DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<comm.DataAdapter.Fill|API> {0}, dataTables[], dataReader, startRecord, maxRecords", ObjectID);

            try
            {
                ADP.CheckArgumentLength(dataTables, nameof(dataTables));
                if ((null == dataTables) || (0 == dataTables.Length) || (null == dataTables[0]))
                {
                    throw ADP.FillRequires("dataTable");
                }
                if (null == dataReader)
                {
                    throw ADP.FillRequires(nameof(dataReader));
                }
                if ((1 < dataTables.Length) && ((0 != startRecord) || (0 != maxRecords)))
                {
                    throw ADP.NotSupported(); // FillChildren is not supported with FillPage
                }

                int     result            = 0;
                bool    enforceContraints = false;
                DataSet commonDataSet     = dataTables[0].DataSet;
                try
                {
                    if (null != commonDataSet)
                    {
                        enforceContraints = commonDataSet.EnforceConstraints;
                        commonDataSet.EnforceConstraints = false;
                    }
                    for (int i = 0; i < dataTables.Length; ++i)
                    {
                        Debug.Assert(null != dataTables[i], "null DataTable Fill");

                        if (dataReader.IsClosed)
                        {
#if DEBUG
                            Debug.Assert(!_debugHookNonEmptySelectCommand, "Debug hook asserts data reader should be open");
#endif
                            break;
                        }
                        DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes);
                        AssertReaderHandleFieldCount(readerHandler);
                        if (readerHandler.FieldCount <= 0)
                        {
                            if (i == 0)
                            {
                                bool lastFillNextResult;
                                do
                                {
                                    lastFillNextResult = FillNextResult(readerHandler);
                                }while (lastFillNextResult && readerHandler.FieldCount <= 0);
                                if (!lastFillNextResult)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if ((0 < i) && !FillNextResult(readerHandler))
                        {
                            break;
                        }
                        // user must Close/Dispose of the dataReader
                        // user will have to call NextResult to access remaining results
                        int count = FillFromReader(null, dataTables[i], null, readerHandler, startRecord, maxRecords, null, null);
                        if (0 == i)
                        {
                            result = count;
                        }
                    }
                }
                catch (ConstraintException)
                {
                    enforceContraints = false;
                    throw;
                }
                finally
                {
                    if (enforceContraints)
                    {
                        commonDataSet.EnforceConstraints = true;
                    }
                }
                return(result);
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }
コード例 #7
0
        protected virtual int Fill(DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords)
        {
            int    num3;
            IntPtr ptr;

            Bid.ScopeEnter(out ptr, "<comm.DataAdapter.Fill|API> %d#, dataTables[], dataReader, startRecord, maxRecords\n", this.ObjectID);
            try
            {
                ADP.CheckArgumentLength(dataTables, "tables");
                if (((dataTables == null) || (dataTables.Length == 0)) || (dataTables[0] == null))
                {
                    throw ADP.FillRequires("dataTable");
                }
                if (dataReader == null)
                {
                    throw ADP.FillRequires("dataReader");
                }
                if ((1 < dataTables.Length) && ((startRecord != 0) || (maxRecords != 0)))
                {
                    throw ADP.NotSupported();
                }
                int     num2 = 0;
                bool    enforceConstraints = false;
                DataSet dataSet            = dataTables[0].DataSet;
                try
                {
                    if (dataSet != null)
                    {
                        enforceConstraints         = dataSet.EnforceConstraints;
                        dataSet.EnforceConstraints = false;
                    }
                    for (int i = 0; i < dataTables.Length; i++)
                    {
                        if (dataReader.IsClosed)
                        {
                            goto Label_00DE;
                        }
                        DataReaderContainer container = DataReaderContainer.Create(dataReader, this.ReturnProviderSpecificTypes);
                        if (container.FieldCount > 0)
                        {
                            if ((0 < i) && !this.FillNextResult(container))
                            {
                                goto Label_00DE;
                            }
                            int num4 = this.FillFromReader(null, dataTables[i], null, container, startRecord, maxRecords, null, null);
                            if (i == 0)
                            {
                                num2 = num4;
                            }
                        }
                    }
                }
                catch (ConstraintException)
                {
                    enforceConstraints = false;
                    throw;
                }
                finally
                {
                    if (enforceConstraints)
                    {
                        dataSet.EnforceConstraints = true;
                    }
                }
Label_00DE:
                num3 = num2;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(num3);
        }