示例#1
0
 /// <summary>
 /// Determines whether the specified <see cref="KeyColumn"/> is present in this collection.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 /// <returns>Whether the specified <see cref="KeyColumn"/> is present in this collection.</returns>
 public bool Contains(KeyColumn keyColumn)
 {
     return List.Contains(keyColumn);
 }
示例#2
0
        /// <summary>
        /// Creates a <see cref="TableDefinition"/> object from a <see cref="JET_OPENTEMPORARYTABLE"/>
        /// object, suitable for caching.
        /// </summary>
        /// <param name="tableDefinition">The table definition.</param>
        /// <param name="openTemporaryTable">The open temporary table.</param>
        /// <returns>A <see cref="TableDefinition"/> object suitable for caching.</returns>
        private static TableDefinition MakeTableDefinitionToCache(
            TableDefinition tableDefinition,
            JET_OPENTEMPORARYTABLE openTemporaryTable)
        {
            // set the new table properties
            TableDefinition tableDefinitionToCache = new TableDefinition(tableDefinition.Name, tableDefinition.Type);

            // add the columns complete with the columnids generated when the
            // TT was created
            //
            // NOTE:  this processing loop has to mirror the loop used to generate
            // the columndefs in MakeOpenTemporaryTable
            int currentColumndef = 0;

            foreach (IndexDefinition indexDefinition in tableDefinition.Indices)
            {
                foreach (KeyColumn keyColumn in indexDefinition.KeyColumns)
                {
                    ColumnDefinition columnDefinition = tableDefinition.Columns[keyColumn.Name];

                    Columnid columnid = new Columnid(
                        columnDefinition.Name,
                        openTemporaryTable.prgcolumnid[currentColumndef],
                        DatabaseCommon.ColtypFromColumnDefinition(columnDefinition),
                        columnDefinition.IsAscii);

                    ColumnDefinition columnDefinitionToCache = new ColumnDefinition(columnid);

                    columnDefinitionToCache.Flags     = columnDefinition.Flags;
                    columnDefinitionToCache.MaxLength = columnDefinition.MaxLength;

                    columnDefinitionToCache.ReadOnly = true;

                    tableDefinitionToCache.Columns.Add(columnDefinitionToCache);

                    currentColumndef++;
                }
            }

            // next collect the rest of the columns and put them after the key
            // columns, skipping over the columns we already added
            foreach (ColumnDefinition columnDefinition in tableDefinition.Columns)
            {
                bool alreadyAdded = false;
                foreach (IndexDefinition indexDefinition in tableDefinition.Indices)
                {
                    foreach (KeyColumn keyColumn in indexDefinition.KeyColumns)
                    {
                        if (keyColumn.Name.ToLower(CultureInfo.InvariantCulture) == columnDefinition.Name.ToLower(CultureInfo.InvariantCulture))
                        {
                            alreadyAdded = true;
                        }
                    }
                }

                if (!alreadyAdded)
                {
                    Columnid columnid = new Columnid(
                        columnDefinition.Name,
                        openTemporaryTable.prgcolumnid[currentColumndef],
                        DatabaseCommon.ColtypFromColumnDefinition(columnDefinition),
                        columnDefinition.IsAscii);

                    ColumnDefinition columnDefinitionToCache = new ColumnDefinition(columnid);

                    columnDefinitionToCache.Flags     = columnDefinition.Flags;
                    columnDefinitionToCache.MaxLength = columnDefinition.MaxLength;

                    columnDefinitionToCache.ReadOnly = true;

                    tableDefinitionToCache.Columns.Add(columnDefinitionToCache);

                    currentColumndef++;
                }
            }

            tableDefinitionToCache.Columns.ReadOnly = true;

            // add the indices
            foreach (IndexDefinition indexDefinition in tableDefinition.Indices)
            {
                IndexDefinition indexDefinitionToCache = new IndexDefinition(indexDefinition.Name);

                indexDefinitionToCache.Flags          = indexDefinition.Flags;
                indexDefinitionToCache.Density        = 100;
                indexDefinitionToCache.CultureInfo    = indexDefinition.CultureInfo;
                indexDefinitionToCache.CompareOptions = indexDefinition.CompareOptions;
                indexDefinitionToCache.MaxKeyLength   = indexDefinition.MaxKeyLength;

                foreach (KeyColumn keyColumn in indexDefinition.KeyColumns)
                {
                    Columnid columnid = tableDefinitionToCache.Columns[keyColumn.Name].Columnid;

                    KeyColumn keyColumnToCache = new KeyColumn(columnid, keyColumn.IsAscending);

                    indexDefinitionToCache.KeyColumns.Add(keyColumnToCache);
                }

                indexDefinitionToCache.KeyColumns.ReadOnly = true;

                indexDefinitionToCache.ReadOnly = true;

                tableDefinitionToCache.Indices.Add(indexDefinitionToCache);
            }

            tableDefinitionToCache.Indices.ReadOnly = true;

            // return the table definition
            return(tableDefinitionToCache);
        }
示例#3
0
 /// <summary>
 /// Removes the specified key column.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 public void Remove(KeyColumn keyColumn)
 {
     List.Remove(keyColumn);
 }
示例#4
0
 /// <summary>
 /// Adds the specified key column.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 public void Add(KeyColumn keyColumn)
 {
     List.Add(keyColumn);
 }
示例#5
0
 /// <summary>
 /// Gets the index of the specified <see cref="KeyColumn"/>.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 /// <returns>An index to be used.</returns>
 public int IndexOf(KeyColumn keyColumn)
 {
     return List.IndexOf(keyColumn);
 }
示例#6
0
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="keyColumn">The key column.</param>
 public void Insert(int index, KeyColumn keyColumn)
 {
     List.Insert(index, keyColumn);
 }
 /// <summary>
 /// Removes the specified key column.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 public void Remove(KeyColumn keyColumn)
 {
     List.Remove(keyColumn);
 }
 /// <summary>
 /// Inserts the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="keyColumn">The key column.</param>
 public void Insert(int index, KeyColumn keyColumn)
 {
     List.Insert(index, keyColumn);
 }
 /// <summary>
 /// Gets the index of the specified <see cref="KeyColumn"/>.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 /// <returns>An index to be used.</returns>
 public int IndexOf(KeyColumn keyColumn)
 {
     return(List.IndexOf(keyColumn));
 }
 /// <summary>
 /// Adds the specified key column.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 public void Add(KeyColumn keyColumn)
 {
     List.Add(keyColumn);
 }
 /// <summary>
 /// Determines whether the specified <see cref="KeyColumn"/> is present in this collection.
 /// </summary>
 /// <param name="keyColumn">The key column.</param>
 /// <returns>Whether the specified <see cref="KeyColumn"/> is present in this collection.</returns>
 public bool Contains(KeyColumn keyColumn)
 {
     return(List.Contains(keyColumn));
 }