コード例 #1
0
        public void Add()
        {
            ConstraintCollection col = _table.Constraints;

            col.Add(_constraint1);
            col.Add(_constraint2);

            Assert.That(col.Count, Is.EqualTo(2), "Count doesn't equal added.");
        }
        public void Add()
        {
            ConstraintCollection col = _table.Constraints;

            col.Add(_constraint1);
            col.Add(_constraint2);

            AssertEquals("Count doesn't equal added.", 2, col.Count);
        }
コード例 #3
0
        public void Add()
        {
            ConstraintCollection col = _table.Constraints;

            col.Add(_constraint1);
            col.Add(_constraint2);

            Assert.Equal(2, col.Count);
        }
コード例 #4
0
        public void AddExceptions()
        {
            ConstraintCollection col = _table.Constraints;

            Assert.Throws <ArgumentNullException>(() => col.Add(null));

            _constraint1.ConstraintName = "Dog";
            col.Add(_constraint1);
            Assert.Throws <DataException>(() => col.Add(_constraint1));
        }
コード例 #5
0
        public void AddExceptions()
        {
            ConstraintCollection col = _table.Constraints;

            //null
            try {
                col.Add(null);
                Assert.Fail("B1: Failed to throw ArgumentNullException.");
            } catch (ArgumentNullException) {
            } catch (AssertionException exc) {
                throw exc;
            } catch {
                Assert.Fail("A1: Wrong exception type");
            }

            //duplicate name
            try {
                _constraint1.ConstraintName = "Dog";
                _constraint2.ConstraintName = "dog";                 //case insensitive
                col.Add(_constraint1);
                col.Add(_constraint2);
                col.Remove(_constraint2);                  // only for !1.0
                col.Remove(_constraint1);
            }
            catch (AssertionException exc) {
                throw exc;
            }

/* Don't use such catch. They cover our eyes from the exact exception location.
 *                      catch (Exception exc)
 *                      {
 *                              Assert.Fail("A2: Wrong exception type. " + exc.ToString());
 *                      }
 */
            //Constraint Already exists
            try {
                col.Add(_constraint1);
                col.Remove(_constraint1);
            } catch (ArgumentException) {
            } catch (AssertionException exc) {
                throw exc;
            } catch {
                Assert.Fail("A3: Wrong exception type");
            }
        }
コード例 #6
0
        internal static VariantConfigurationSnapshot GetSnapshot(ADRawEntry executingUser, IEnumerable <KeyValuePair <string, string> > additionalConstraints)
        {
            if (executingUser == null)
            {
                return(null);
            }
            VariantConfigurationSnapshot variantConfigurationSnapshot = null;
            MiniRecipient miniRecipient = new MiniRecipient();

            try
            {
                try
                {
                    miniRecipient[MiniRecipientSchema.UserPrincipalName]         = executingUser[ADUserSchema.UserPrincipalName];
                    miniRecipient[ADObjectSchema.OrganizationId]                 = executingUser[ADObjectSchema.OrganizationId];
                    miniRecipient[MiniRecipientSchema.ExternalDirectoryObjectId] = executingUser[ADRecipientSchema.ExternalDirectoryObjectId];
                    miniRecipient[MiniRecipientSchema.Languages]                 = executingUser[ADOrgPersonSchema.Languages];
                }
                catch (DataValidationException ex)
                {
                    AuthZLogger.SafeAppendColumn(RpsAuthZMetadata.VariantConfigurationSnapshot, "DataValidationException", ex.Message);
                }
                ConstraintCollection constraintCollection = null;
                if (additionalConstraints != null)
                {
                    constraintCollection = ConstraintCollection.CreateEmpty();
                    foreach (KeyValuePair <string, string> keyValuePair in additionalConstraints)
                    {
                        constraintCollection.Add(keyValuePair.Key, keyValuePair.Value);
                    }
                }
                variantConfigurationSnapshot = VariantConfiguration.GetSnapshot(miniRecipient.GetContext(null), constraintCollection, null);
                AuthZLogger.SafeAppendColumn(RpsAuthZMetadata.VariantConfigurationSnapshot, "Flights", string.Join(" ", variantConfigurationSnapshot.Flights));
            }
            catch (Exception ex2)
            {
                AuthZLogger.SafeAppendGenericError("VariantConfigurationSnapshot.Exception", ex2.Message, false);
            }
            finally
            {
                AuthZLogger.SafeAppendColumn(RpsAuthZMetadata.VariantConfigurationSnapshot, "User", executingUser[ADUserSchema.UserPrincipalName].ToString());
                AuthZLogger.SafeAppendColumn(RpsAuthZMetadata.VariantConfigurationSnapshot, "Org", executingUser[ADObjectSchema.OrganizationId].ToString());
            }
            return(variantConfigurationSnapshot);
        }
コード例 #7
0
        protected internal Viewport2D(FrameworkElement host, Plotter2D plotter)
        {
            hostElement = host;
            host.ClipToBounds = true;
            host.SizeChanged += OnHostElementSizeChanged;

            this.plotter = plotter;
            plotter.Children.CollectionChanged += OnPlotterChildrenChanged;

            constraints = new ConstraintCollection(this);
			constraints.Add(new MinimalSizeConstraint());
			constraints.CollectionChanged += constraints_CollectionChanged;

			fitToViewConstraints = new ConstraintCollection(this);
			fitToViewConstraints.CollectionChanged += fitToViewConstraints_CollectionChanged;

            readonlyContentBoundsHosts = new ReadOnlyObservableCollection<DependencyObject>(contentBoundsHosts);

            UpdateVisible();
            UpdateTransform();
        }
コード例 #8
0
ファイル: Viewport2D.cs プロジェクト: gr001/PeaksProcessing2
        protected internal Viewport2D(FrameworkElement host, Plotter2D plotter)
        {
            hostElement       = host;
            host.ClipToBounds = true;
            host.SizeChanged += OnHostElementSizeChanged;

            this.plotter = plotter;
            plotter.Children.CollectionChanged += OnPlotterChildrenChanged;

            constraints = new ConstraintCollection(this);
            constraints.Add(new MinimalSizeConstraint());
            constraints.CollectionChanged += constraints_CollectionChanged;

            fitToViewConstraints = new ConstraintCollection(this);
            fitToViewConstraints.CollectionChanged += fitToViewConstraints_CollectionChanged;

            readonlyContentBoundsHosts = new ReadOnlyObservableCollection <DependencyObject>(contentBoundsHosts);

            UpdateVisible();
            UpdateTransform();
        }
コード例 #9
0
ファイル: labtechDataSet.cs プロジェクト: joebartt/LTQATools
            private void InitClass()
            {
                this.columnComputerID = new DataColumn("ComputerID", typeof(int), null, MappingType.Element);
                base.Columns.Add(this.columnComputerID);
                this.columnName = new DataColumn("Name", typeof(string), null, MappingType.Element);
                base.Columns.Add(this.columnName);
                this.columnflags = new DataColumn("flags", typeof(int), null, MappingType.Element);
                base.Columns.Add(this.columnflags);
                this.columnFeatureFlags = new DataColumn("FeatureFlags", typeof(int), null, MappingType.Element);
                base.Columns.Add(this.columnFeatureFlags);
                ConstraintCollection constraints = base.Constraints;

                DataColumn[] dataColumnArray = new DataColumn[] { this.columnComputerID };
                constraints.Add(new UniqueConstraint("Constraint1", dataColumnArray, true));
                this.columnComputerID.AutoIncrement     = true;
                this.columnComputerID.AutoIncrementSeed = (long)-1;
                this.columnComputerID.AutoIncrementStep = (long)-1;
                this.columnComputerID.AllowDBNull       = false;
                this.columnComputerID.Unique            = true;
                this.columnName.AllowDBNull             = false;
                this.columnName.MaxLength           = 50;
                this.columnflags.AllowDBNull        = false;
                this.columnFeatureFlags.AllowDBNull = false;
            }
コード例 #10
0
        private object[] SetupSchemaWithKeyInfo(MissingMappingAction mappingAction, MissingSchemaAction schemaAction, bool gettingData, DataColumn parentChapterColumn, object chapterValue)
        {
            DbSchemaRow[] sortedSchemaRows = DbSchemaRow.GetSortedSchemaRows(this._schemaTable, this._dataReader.ReturnProviderSpecificTypes);
            if (sortedSchemaRows.Length == 0)
            {
                this._dataTable = null;
                return(null);
            }
            bool flag3 = ((this._dataTable.PrimaryKey.Length == 0) && ((((LoadOption)4) <= this._loadOption) || (this._dataTable.Rows.Count == 0))) || (0 == this._dataTable.Columns.Count);

            DataColumn[] rgcol = null;
            int          len   = 0;
            bool         flag2 = true;
            string       str3  = null;
            string       str2  = null;
            bool         flag6 = false;
            bool         flag  = false;

            int[]  numArray  = null;
            bool[] flagArray = null;
            int    num3      = 0;

            object[]             objArray         = null;
            List <object>        items            = null;
            DataColumnCollection columnCollection = this._dataTable.Columns;

            try
            {
                for (int i = 0; i < sortedSchemaRows.Length; i++)
                {
                    DbSchemaRow row           = sortedSchemaRows[i];
                    int         unsortedIndex = row.UnsortedIndex;
                    bool        flag5         = false;
                    Type        dataType      = row.DataType;
                    if (null == dataType)
                    {
                        dataType = this._dataReader.GetFieldType(i);
                    }
                    if (null == dataType)
                    {
                        throw ADP.MissingDataReaderFieldType(i);
                    }
                    if (typeof(IDataReader).IsAssignableFrom(dataType))
                    {
                        if (flagArray == null)
                        {
                            flagArray = new bool[sortedSchemaRows.Length];
                        }
                        flagArray[unsortedIndex] = flag5 = true;
                        dataType = typeof(int);
                    }
                    else if (typeof(System.Data.SqlTypes.SqlXml).IsAssignableFrom(dataType))
                    {
                        if (this._xmlMap == null)
                        {
                            this._xmlMap = new int[sortedSchemaRows.Length];
                        }
                        this._xmlMap[i] = 1;
                    }
                    else if (typeof(XmlReader).IsAssignableFrom(dataType))
                    {
                        dataType = typeof(string);
                        if (this._xmlMap == null)
                        {
                            this._xmlMap = new int[sortedSchemaRows.Length];
                        }
                        this._xmlMap[i] = 2;
                    }
                    DataColumn targetColumn = null;
                    if (!row.IsHidden)
                    {
                        targetColumn = this._tableMapping.GetDataColumn(this._fieldNames[i], dataType, this._dataTable, mappingAction, schemaAction);
                    }
                    string baseTableName = row.BaseTableName;
                    if (targetColumn == null)
                    {
                        if (numArray == null)
                        {
                            numArray = this.CreateIndexMap(sortedSchemaRows.Length, unsortedIndex);
                        }
                        numArray[unsortedIndex] = -1;
                        if (row.IsKey && (flag6 || (row.BaseTableName == str3)))
                        {
                            flag3 = false;
                            rgcol = null;
                        }
                    }
                    else
                    {
                        if ((this._xmlMap != null) && (this._xmlMap[i] != 0))
                        {
                            if (typeof(System.Data.SqlTypes.SqlXml) == targetColumn.DataType)
                            {
                                this._xmlMap[i] = 1;
                            }
                            else if (typeof(System.Xml.XmlDocument) == targetColumn.DataType)
                            {
                                this._xmlMap[i] = 2;
                            }
                            else
                            {
                                this._xmlMap[i] = 0;
                                int num7 = 0;
                                for (int j = 0; j < this._xmlMap.Length; j++)
                                {
                                    num7 += this._xmlMap[j];
                                }
                                if (num7 == 0)
                                {
                                    this._xmlMap = null;
                                }
                            }
                        }
                        if (row.IsKey && (baseTableName != str3))
                        {
                            if (str3 == null)
                            {
                                str3 = baseTableName;
                            }
                            else
                            {
                                flag6 = true;
                            }
                        }
                        if (flag5)
                        {
                            if (targetColumn.Table != null)
                            {
                                if (!targetColumn.AutoIncrement)
                                {
                                    throw ADP.FillChapterAutoIncrement();
                                }
                            }
                            else
                            {
                                targetColumn.AllowDBNull   = false;
                                targetColumn.AutoIncrement = true;
                                targetColumn.ReadOnly      = true;
                            }
                        }
                        else
                        {
                            if ((!flag && (baseTableName != str2)) && !ADP.IsEmpty(baseTableName))
                            {
                                if (str2 == null)
                                {
                                    str2 = baseTableName;
                                }
                                else
                                {
                                    flag = true;
                                }
                            }
                            if (((LoadOption)4) <= this._loadOption)
                            {
                                if (row.IsAutoIncrement && DataColumn.IsAutoIncrementType(dataType))
                                {
                                    targetColumn.AutoIncrement = true;
                                    if (!row.AllowDBNull)
                                    {
                                        targetColumn.AllowDBNull = false;
                                    }
                                }
                                if (dataType == typeof(string))
                                {
                                    targetColumn.MaxLength = (row.Size > 0) ? row.Size : -1;
                                }
                                if (row.IsReadOnly)
                                {
                                    targetColumn.ReadOnly = true;
                                }
                                if (!row.AllowDBNull && (!row.IsReadOnly || row.IsKey))
                                {
                                    targetColumn.AllowDBNull = false;
                                }
                                if ((row.IsUnique && !row.IsKey) && !dataType.IsArray)
                                {
                                    targetColumn.Unique = true;
                                    if (!row.AllowDBNull)
                                    {
                                        targetColumn.AllowDBNull = false;
                                    }
                                }
                            }
                            else if (targetColumn.Table == null)
                            {
                                targetColumn.AutoIncrement = row.IsAutoIncrement;
                                targetColumn.AllowDBNull   = row.AllowDBNull;
                                targetColumn.ReadOnly      = row.IsReadOnly;
                                targetColumn.Unique        = row.IsUnique;
                                if ((dataType == typeof(string)) || (dataType == typeof(SqlString)))
                                {
                                    targetColumn.MaxLength = row.Size;
                                }
                            }
                        }
                        if (targetColumn.Table == null)
                        {
                            if (((LoadOption)4) > this._loadOption)
                            {
                                this.AddAdditionalProperties(targetColumn, row.DataRow);
                            }
                            this.AddItemToAllowRollback(ref items, targetColumn);
                            columnCollection.Add(targetColumn);
                        }
                        if (flag3 && row.IsKey)
                        {
                            if (rgcol == null)
                            {
                                rgcol = new DataColumn[sortedSchemaRows.Length];
                            }
                            rgcol[len++] = targetColumn;
                            if (flag2 && targetColumn.AllowDBNull)
                            {
                                flag2 = false;
                            }
                        }
                        if (numArray != null)
                        {
                            numArray[unsortedIndex] = targetColumn.Ordinal;
                        }
                        else if (unsortedIndex != targetColumn.Ordinal)
                        {
                            numArray = this.CreateIndexMap(sortedSchemaRows.Length, unsortedIndex);
                            numArray[unsortedIndex] = targetColumn.Ordinal;
                        }
                        num3++;
                    }
                }
                bool       flag4   = false;
                DataColumn column2 = null;
                if (chapterValue != null)
                {
                    Type type = chapterValue.GetType();
                    column2 = this._tableMapping.GetDataColumn(this._tableMapping.SourceTable, type, this._dataTable, mappingAction, schemaAction);
                    if (column2 != null)
                    {
                        if (column2.Table == null)
                        {
                            column2.ReadOnly    = true;
                            column2.AllowDBNull = false;
                            this.AddItemToAllowRollback(ref items, column2);
                            columnCollection.Add(column2);
                            flag4 = null != parentChapterColumn;
                        }
                        num3++;
                    }
                }
                if (0 < num3)
                {
                    if ((this._dataSet != null) && (this._dataTable.DataSet == null))
                    {
                        this.AddItemToAllowRollback(ref items, this._dataTable);
                        this._dataSet.Tables.Add(this._dataTable);
                    }
                    if (flag3 && (rgcol != null))
                    {
                        if (len < rgcol.Length)
                        {
                            rgcol = this.ResizeColumnArray(rgcol, len);
                        }
                        if (flag2)
                        {
                            this._dataTable.PrimaryKey = rgcol;
                        }
                        else
                        {
                            UniqueConstraint     constraint  = new UniqueConstraint("", rgcol);
                            ConstraintCollection constraints = this._dataTable.Constraints;
                            int count = constraints.Count;
                            for (int k = 0; k < count; k++)
                            {
                                if (constraint.Equals(constraints[k]))
                                {
                                    constraint = null;
                                    break;
                                }
                            }
                            if (constraint != null)
                            {
                                constraints.Add(constraint);
                            }
                        }
                    }
                    if ((!flag && !ADP.IsEmpty(str2)) && ADP.IsEmpty(this._dataTable.TableName))
                    {
                        this._dataTable.TableName = str2;
                    }
                    if (gettingData)
                    {
                        this._indexMap   = numArray;
                        this._chapterMap = flagArray;
                        objArray         = this.SetupMapping(sortedSchemaRows.Length, columnCollection, column2, chapterValue);
                    }
                    else
                    {
                        this._mappedMode = -1;
                    }
                }
                else
                {
                    this._dataTable = null;
                }
                if (flag4)
                {
                    this.AddRelation(parentChapterColumn, column2);
                }
            }
            catch (Exception exception)
            {
                if (ADP.IsCatchableOrSecurityExceptionType(exception))
                {
                    this.RollbackAddedItems(items);
                }
                throw;
            }
            return(objArray);
        }
コード例 #11
0
        private void SetupSchemaWithKeyInfo(MissingMappingAction mappingAction, MissingSchemaAction schemaAction, bool gettingData, DataColumn parentChapterColumn, object chapterValue)
        {
#if DEBUG
            Debug.Assert(null != schemaTable, "null schematable");
            if (AdapterSwitches.DataSchema.TraceVerbose)
            {
                ADP.TraceDataTable("SetupSchema", schemaTable);
            }
#endif
            DBSchemaRow[] schemaRows = DBSchemaRow.GetSortedSchemaRows(schemaTable); // MDAC 60609
            Debug.Assert(null != schemaRows, "SchemaSetup - null DBSchemaRow[]");

            int count = schemaRows.Length;
            if (0 == count)
            {
                this.dataTable = null;
                return;
            }

            bool         addPrimaryKeys = (0 == this.dataTable.PrimaryKey.Length); // MDAC 67033
            DataColumn[] keys           = null;
            int          keyCount       = 0;
            bool         isPrimary      = true; // assume key info (if any) is about a primary key

            int[]  columnIndexMap  = null;
            bool[] chapterIndexMap = null;

            int mappingCount = 0;
            GenerateFieldNames(count);

            DataColumnCollection columnCollection = null;
            for (int sortedIndex = 0; sortedIndex < count; ++sortedIndex)
            {
                DBSchemaRow schemaRow = schemaRows[sortedIndex];

                int unsortedIndex = schemaRow.UnsortedIndex; // MDAC 67050

                DataColumnMapping columnMapping = null;
                Type       fieldType            = schemaRow.DataType;
                DataColumn dataColumn           = null;

                if (!schemaRow.IsHidden)
                {
                    columnMapping = tableMapping.GetColumnMappingBySchemaAction(fieldNames[sortedIndex], mappingAction);
                }

                bool ischapter = false;
                if ((null != columnMapping) && typeof(IDataReader).IsAssignableFrom(fieldType))
                {
                    if (null == chapterIndexMap)
                    {
                        chapterIndexMap = new bool[count];
                    }
                    chapterIndexMap[unsortedIndex] = ischapter = true;

                    fieldType = typeof(Int32);
                }

                if (columnMapping != null)
                {
                    dataColumn = columnMapping.GetDataColumnBySchemaAction(this.dataTable, fieldType, schemaAction);
                }

                if (null == dataColumn)
                {
                    if (null == columnIndexMap)
                    {
                        columnIndexMap = CreateIndexMap(count, unsortedIndex);
                    }
                    columnIndexMap[unsortedIndex] = -1;

                    // if the column is not mapped and it is a key, then don't add any key information
                    if (schemaRow.IsKey)
                    {
#if DEBUG
                        if (AdapterSwitches.DataSchema.TraceVerbose)
                        {
                            Debug.WriteLine("SetupSchema: partial primary key detected");
                        }
#endif
                        addPrimaryKeys = false; // don't add any future keys now
                        keys           = null;  // get rid of any keys we've seen
                    }
                    continue;                   // null means ignore (mapped to nothing)
                }

                if (ischapter)
                {
                    if (null == dataColumn.Table)
                    {
                        dataColumn.AllowDBNull   = false;
                        dataColumn.AutoIncrement = true;
                        dataColumn.ReadOnly      = true;
                    }
                    else if (!dataColumn.AutoIncrement)
                    {
                        throw ADP.FillChapterAutoIncrement();
                    }
                }
                else  // MDAC 67033
                {
                    if (schemaRow.IsAutoIncrement && IsAutoIncrementType(fieldType))
                    {
                        // CONSIDER: use T-SQL "IDENT_INCR('table_or_view')" and "IDENT_SEED('table_or_view')"
                        //           functions to obtain the actual increment and seed values
                        dataColumn.AutoIncrement = true;

                        if (!schemaRow.AllowDBNull)   // MDAC 71060
                        {
                            dataColumn.AllowDBNull = false;
                        }
                    }

                    // setup maxLength, only for string columns since this is all the DataSet supports
                    if (fieldType == typeof(string))
                    {
                        //@devnote:  schemaRow.Size is count of characters for string columns, count of bytes otherwise
                        dataColumn.MaxLength = schemaRow.Size;
                    }

                    if (schemaRow.IsReadOnly)
                    {
                        dataColumn.ReadOnly = true;
                    }
                    if (!schemaRow.AllowDBNull && (!schemaRow.IsReadOnly || schemaRow.IsKey))   // MDAC 71060, 72252
                    {
                        dataColumn.AllowDBNull = false;
                    }

                    if (schemaRow.IsUnique && !schemaRow.IsKey && !fieldType.IsArray)
                    {
                        // note, arrays are not comparable so only mark non-arrays as unique, ie timestamp columns
                        // are unique, but not comparable
                        dataColumn.Unique = true;

                        if (!schemaRow.AllowDBNull)   // MDAC 71060
                        {
                            dataColumn.AllowDBNull = false;
                        }
                    }
                }
                if (null == dataColumn.Table)
                {
                    if (null == columnCollection)
                    {
                        columnCollection = dataTable.Columns;
                    }
                    columnCollection.Add(dataColumn);
                }

                // The server sends us one key per table according to these rules.
                //
                // 1. If the table has a primary key, the server sends us this key.
                // 2. If the table has a primary key and a unique key, it sends us the primary key
                // 3. if the table has no primary key but has a unique key, it sends us the unique key
                //
                // In case 3, we will promote a unique key to a primary key IFF all the columns that compose
                // that key are not nullable since no columns in a primary key can be null.  If one or more
                // of the keys is nullable, then we will add a unique constraint.
                //
                if (addPrimaryKeys && schemaRow.IsKey)   // MDAC 67033
                {
                    if (keys == null)
                    {
                        keys = new DataColumn[count];
                    }
                    keys[keyCount++] = dataColumn;
#if DEBUG
                    if (AdapterSwitches.DataSchema.TraceVerbose)
                    {
                        Debug.WriteLine("SetupSchema: building list of " + ((isPrimary) ? "PrimaryKey" : "UniqueConstraint"));
                    }
#endif
                    // see case 3 above, we do want dataColumn.AllowDBNull not schemaRow.AllowDBNull
                    // otherwise adding PrimaryKey will change AllowDBNull to false
                    if (isPrimary && dataColumn.AllowDBNull)   // MDAC 72241
                    {
#if DEBUG
                        if (AdapterSwitches.DataSchema.TraceVerbose)
                        {
                            Debug.WriteLine("SetupSchema: changing PrimaryKey into UniqueContraint");
                        }
#endif
                        isPrimary = false;
                    }
                }

                if (null != columnIndexMap)
                {
                    columnIndexMap[unsortedIndex] = dataColumn.Ordinal;
                }
                else if (unsortedIndex != dataColumn.Ordinal)
                {
                    columnIndexMap = CreateIndexMap(count, unsortedIndex);
                    columnIndexMap[unsortedIndex] = dataColumn.Ordinal;
                }
                mappingCount++;
            }

            bool       addDataRelation = false;
            DataColumn chapterColumn   = null;
            if (null != chapterValue)   // add the extra column in the child table
            {
                DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(tableMapping.SourceTable, mappingAction);
                if (null != columnMapping)
                {
                    Type fieldType = chapterValue.GetType();
                    chapterColumn = columnMapping.GetDataColumnBySchemaAction(this.dataTable, fieldType, schemaAction);
                    if (null != chapterColumn)
                    {
                        if (null == chapterColumn.Table)
                        {
                            chapterColumn.ReadOnly    = true; // MDAC 71878
                            chapterColumn.AllowDBNull = false;

                            if (null == columnCollection)
                            {
                                columnCollection = dataTable.Columns;
                            }
                            columnCollection.Add(chapterColumn);
                            addDataRelation = (null != parentChapterColumn);
                        }
                        mappingCount++;
                    }
                }
            }

            object[] dataValues = null;
            if (0 < mappingCount)
            {
                if ((null != this.dataSet) && null == this.dataTable.DataSet)
                {
                    this.dataSet.Tables.Add(this.dataTable);
                }
                // setup the key
                if (addPrimaryKeys && (null != keys))   // MDAC 67033
                {
                    if (keyCount < keys.Length)
                    {
                        keys = ResizeColumnArray(keys, keyCount);
                    }

                    // MDAC 66188
                    if (isPrimary)
                    {
#if DEBUG
                        if (AdapterSwitches.DataSchema.TraceVerbose)
                        {
                            Debug.WriteLine("SetupSchema: set_PrimaryKey");
                        }
#endif
                        this.dataTable.PrimaryKey = keys;
                    }
                    else
                    {
                        UniqueConstraint     unique      = new UniqueConstraint("", keys);
                        ConstraintCollection constraints = this.dataTable.Constraints;
                        int constraintCount = constraints.Count;
                        for (int i = 0; i < constraintCount; ++i)
                        {
                            if (unique.Equals(constraints[i]))
                            {
#if DEBUG
                                if (AdapterSwitches.DataSchema.TraceVerbose)
                                {
                                    Debug.WriteLine("SetupSchema: duplicate Contraint detected");
                                }
#endif
                                unique = null;
                                break;
                            }
                        }
                        if (null != unique)
                        {
#if DEBUG
                            if (AdapterSwitches.DataSchema.TraceVerbose)
                            {
                                Debug.WriteLine("SetupSchema: adding new UniqueConstraint");
                            }
#endif
                            constraints.Add(unique);
                        }
                    }
                }
                if (gettingData)
                {
                    if (null == columnCollection)
                    {
                        columnCollection = dataTable.Columns;
                    }
                    _indexMap   = columnIndexMap;
                    _chapterMap = chapterIndexMap;
                    dataValues  = SetupMapping(count, columnCollection, chapterColumn, chapterValue);
                }
#if DEBUG
                else
                {
                    this.mappedMode = -1;
                }
#endif
            }
            else
            {
                this.dataTable = null;
            }
            if (addDataRelation)
            {
                AddRelation(parentChapterColumn, chapterColumn);
            }
            _readerDataValues = dataValues;
        }