当前位置: 首页>>代码示例>>C#>>正文


C# Index.Alter方法代码示例

本文整理汇总了C#中Index.Alter方法的典型用法代码示例。如果您正苦于以下问题:C# Index.Alter方法的具体用法?C# Index.Alter怎么用?C# Index.Alter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Index的用法示例。


在下文中一共展示了Index.Alter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateNewPrimaryKey

        /// <summary>
        /// Recreates primary key or index.
        /// </summary>
        /// <param name="table">Current table <see cref="Table"/></param>
        /// <param name="descriptor">Index descriptor</param>
        private static void CreateNewPrimaryKey(Table table, IndexDbo descriptor)
        {
            var indexKeyType = (IndexKeyType)Enum.Parse(typeof(IndexKeyType), descriptor.IndexKeyType);
            byte fillFactor = (byte)(descriptor.FillFactor ?? 0);

            var primaryKeyIndex = new Index(table, descriptor.Name)
            {
                CompactLargeObjects = descriptor.CompactLargeObjects,
                FillFactor = fillFactor > 0 ? fillFactor : (byte)50,
                FilterDefinition = descriptor.FilterDefinition,
                IgnoreDuplicateKeys = descriptor.IgnoreDuplicateKeys,
                IndexKeyType = indexKeyType,
                IsClustered = descriptor.IsClustered,
                IsUnique = descriptor.IsUnique,
            };
            foreach (string columnName in descriptor.IndexedColumns)
                primaryKeyIndex.IndexedColumns.Add(new IndexedColumn(primaryKeyIndex, columnName));
            primaryKeyIndex.Create();
            primaryKeyIndex.DisallowPageLocks = descriptor.DisallowPageLocks;
            primaryKeyIndex.DisallowRowLocks = descriptor.DisallowRowLocks;
            primaryKeyIndex.Alter();
            //if (descriptor.IsDisabled)
            //{
            //    primaryKeyIndex.Disable();
            //    table.Alter();
            //}
        }
开发者ID:kimanidev,项目名称:CFCDatabase,代码行数:32,代码来源:CfcWebService_Utilities_1.cs

示例2: AddColumnToIndex

        public static void AddColumnToIndex(Table table, Column column, Index ind)
        {
            string oldName = ind.Name;
            var idx = new Index(table, oldName)
            {
                BoundingBoxYMax = ind.BoundingBoxYMax,
                BoundingBoxYMin = ind.BoundingBoxYMin,
                BoundingBoxXMax = ind.BoundingBoxXMax,
                BoundingBoxXMin = ind.BoundingBoxXMin,
                CompactLargeObjects = ind.CompactLargeObjects,
                DisallowRowLocks = ind.DisallowRowLocks,
                FileGroup = ind.FileGroup,
                FileStreamFileGroup = ind.FileStreamFileGroup,
                FileStreamPartitionScheme = ind.FileStreamPartitionScheme,
                FillFactor = ind.FillFactor,
                FilterDefinition = ind.FilterDefinition,
                IgnoreDuplicateKeys = ind.IgnoreDuplicateKeys,
                IndexKeyType = ind.IndexKeyType,
                IsClustered = ind.IsClustered,
                IsFullTextKey = ind.IsFullTextKey,
                IsUnique = ind.IsUnique,
                Level1Grid = ind.Level1Grid,
                Level2Grid = ind.Level2Grid,
                Level3Grid = ind.Level3Grid,
                Level4Grid = ind.Level4Grid,
                MaximumDegreeOfParallelism = ind.MaximumDegreeOfParallelism,
                NoAutomaticRecomputation = ind.NoAutomaticRecomputation,
                OnlineIndexOperation = ind.OnlineIndexOperation,
                PadIndex = ind.PadIndex,
                ParentXmlIndex = ind.ParentXmlIndex,
                PartitionScheme = ind.PartitionScheme,
                SecondaryXmlIndexType = ind.SecondaryXmlIndexType,
                SortInTempdb = ind.SortInTempdb,
                SpatialIndexType = ind.SpatialIndexType,
            };

            foreach (IndexedColumn iColumn in ind.IndexedColumns)
            {
                var newIdxColumn = new IndexedColumn(idx, iColumn.Name)
                {
                    Descending = iColumn.Descending,
                    IsIncluded = iColumn.IsIncluded,
                };
                idx.IndexedColumns.Add(newIdxColumn);
            }
            idx.IndexedColumns.Add(new IndexedColumn(idx, column.Name));

            bool oldDisallowPageLocks = ind.DisallowPageLocks;
            ind.Drop();
            idx.Create();
            idx.DisallowPageLocks = oldDisallowPageLocks;
            idx.Alter();
        }
开发者ID:kimanidev,项目名称:CFCDatabase,代码行数:53,代码来源:CfcWebService_Utilities.cs


注:本文中的Index.Alter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。