System.Data.Common.DbDataAdapter.FillSchemaInternal C# (CSharp) Method

FillSchemaInternal() private method

private FillSchemaInternal ( DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior ) : object
dataset System.Data.DataSet
datatable System.Data.DataTable
schemaType SchemaType
command IDbCommand
srcTable string
behavior CommandBehavior
return object
        private object FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior)
        {
            object dataTables = null;
            bool restoreNullConnection = (null == command.Connection);
            try
            {
                IDbConnection activeConnection = DbDataAdapter.GetConnection3(this, command, ADP.FillSchema);
                ConnectionState originalState = ConnectionState.Open;

                try
                {
                    QuietOpen(activeConnection, out originalState);
                    using (IDataReader dataReader = command.ExecuteReader(behavior | CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo))
                    {
                        if (null != datatable)
                        { // delegate to next set of protected FillSchema methods
                            dataTables = FillSchema(datatable, schemaType, dataReader);
                        }
                        else
                        {
                            dataTables = FillSchema(dataset, schemaType, srcTable, dataReader);
                        }
                    }
                }
                finally
                {
                    QuietClose(activeConnection, originalState);
                }
            }
            finally
            {
                if (restoreNullConnection)
                {
                    command.Transaction = null;
                    command.Connection = null;
                }
            }
            return dataTables;
        }