本文整理汇总了C#中Index.Script方法的典型用法代码示例。如果您正苦于以下问题:C# Index.Script方法的具体用法?C# Index.Script怎么用?C# Index.Script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index.Script方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createStgIndex
private void createStgIndex(Index i, TableViewBase parent)
{
if (i.PartitionScheme == "")
throw (new System.NotSupportedException(
String.Format("The index '{0}' is not aligned to a Partition Scheme", i.Name)));
// todo: differentiate between Base Table as source, and View as source
// LZAV: Index stgIndex = new Index(parent, parent.Name + "_" + i.Name);
String indexName = parent.Name + "_" + i.Name; // LZAV
if (indexName.Length > 128) // LZAV
indexName = "IX_CL_" + parent.Name; // LZAV
Index stgIndex = new Index(parent, indexName); // LZAV
foreach (IndexedColumn iCol in i.IndexedColumns)
{
IndexedColumn stgICol = new IndexedColumn(stgIndex, iCol.Name, iCol.Descending);
stgICol.IsIncluded = iCol.IsIncluded;
stgIndex.IndexedColumns.Add(stgICol);
}
stgIndex.IndexType = i.IndexType;
stgIndex.IndexKeyType = i.IndexKeyType;
stgIndex.IsClustered = i.IsClustered;
stgIndex.IsUnique = i.IsUnique;
stgIndex.CompactLargeObjects = i.CompactLargeObjects;
stgIndex.IgnoreDuplicateKeys = i.IgnoreDuplicateKeys;
stgIndex.IsFullTextKey = i.IsFullTextKey;
stgIndex.PadIndex = i.PadIndex;
stgIndex.FileGroup = db.PartitionSchemes[i.PartitionScheme].FileGroups[partitionNumber - 1];
// add the partitioning column to the index if it is not already there
String partitionKeyName = i.PartitionSchemeParameters[0].Name;
if (stgIndex.IndexedColumns[partitionKeyName] == null)
{
IndexedColumn stgICol = new IndexedColumn(stgIndex, partitionKeyName);
// It is added as a Key to the Clustered index and as an Include column to a Nonclustered
stgICol.IsIncluded = !stgIndex.IsClustered;
stgIndex.IndexedColumns.Add(stgICol);
}
if (srv.VersionMajor >= 10)
{
// Define compression property to match by creating a Physical Partition object (not applicable to Colstore)
{
PhysicalPartition stgPartition = new PhysicalPartition(stgIndex, 1);
if (i.IndexType != IndexType.NonClusteredColumnStoreIndex)
{
stgPartition.DataCompression = i.PhysicalPartitions[partitionNumber - 1].DataCompression;
}
stgIndex.PhysicalPartitions.Add(stgPartition);
}
// Handle Filtered Index
if (i.HasFilter)
{
stgIndex.FilterDefinition = i.FilterDefinition;
}
}
scriptChunks.Add(stgIndex.Script());
if (executeCommands) stgIndex.Create();
}