From 04c64223e22136b52409fe5957a7fd4c5ab910d0 Mon Sep 17 00:00:00 2001 From: Hai Cao Date: Wed, 28 Sep 2022 10:26:59 -0700 Subject: [PATCH] [Table Designer] Only show index hash options when table is memory-optimized (#1714) --- .../Localization/sr.cs | 11 ---- .../Localization/sr.resx | 4 -- .../Localization/sr.strings | 1 - .../Localization/sr.xlf | 5 -- .../TableDesigner/TableDesignerService.cs | 55 ++++++++++--------- 5 files changed, 30 insertions(+), 46 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index 8718d6b2..0a6d17ac 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -8901,14 +8901,6 @@ namespace Microsoft.SqlTools.ServiceLayer } } - public static string HashIndexGroupTitle - { - get - { - return Keys.GetString(Keys.HashIndexGroupTitle); - } - } - public static string TableDesignerColumnsDisplayValueTitle { get @@ -13557,9 +13549,6 @@ namespace Microsoft.SqlTools.ServiceLayer public const string IndexBucketCountPropertyTitle = "IndexBucketCountPropertyTitle"; - public const string HashIndexGroupTitle = "HashIndexGroupTitle"; - - public const string TableDesignerColumnsDisplayValueTitle = "TableDesignerColumnsDisplayValueTitle"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index b4ec5e1a..4ec1a98e 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -4867,10 +4867,6 @@ The Query Processor estimates that implementing the following index could improv Bucket Count - - Hash Index - - Columns diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index fe6ccb2d..9428db7e 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -2302,7 +2302,6 @@ IndexIsHashPropertyDescription = Whether the index is a hash index IndexIsHashPropertyTitle = Is Hash IndexBucketCountPropertyDescription = Bucket count of the hash index, note the value will always automatically round up to the next power of 2. IndexBucketCountPropertyTitle = Bucket Count -HashIndexGroupTitle = Hash Index TableDesignerColumnsDisplayValueTitle = Columns ColumnStoreIndexNamePropertyTitle = Name ColumnStoreIndexNamePropertyDescription = Name of the columnstore index diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index 898a0d12..a60cc386 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -6397,11 +6397,6 @@ The Query Processor estimates that implementing the following index could improv Bucket Count - - Hash Index - Hash Index - - Name Name diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs index 1ee283fe..fd984918 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs @@ -1111,7 +1111,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner this.SetColumnsViewInfo(view); this.SetForeignKeysViewInfo(view); this.SetCheckConstraintsViewInfo(view); - this.SetIndexesViewInfo(view); + this.SetIndexesViewInfo(view, tableDesigner); this.SetColumnStoreIndexesViewInfo(view); this.SetGraphTableViewInfo(view, tableDesigner); this.SetEdgeConstraintsViewInfo(view, tableDesigner); @@ -1298,7 +1298,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner view.CheckConstraintTableOptions.CanInsertRows = false; } - private void SetIndexesViewInfo(TableDesignerView view) + private void SetIndexesViewInfo(TableDesignerView view, Dac.TableDesigner tableDesigner) { view.IndexTableOptions.AdditionalProperties.AddRange(new DesignerDataPropertyInfo[] { new DesignerDataPropertyInfo() @@ -1354,29 +1354,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner } }, new DesignerDataPropertyInfo() - { - PropertyName = IndexPropertyNames.IsHash, - Description = SR.IndexIsHashPropertyDescription, - ComponentType = DesignerComponentType.Checkbox, - Group = SR.HashIndexGroupTitle, - ComponentProperties = new CheckBoxProperties() - { - Title = SR.IndexIsHashPropertyTitle - } - }, - new DesignerDataPropertyInfo() - { - PropertyName = IndexPropertyNames.BucketCount, - Description = SR.IndexBucketCountPropertyDescription, - ComponentType = DesignerComponentType.Input, - Group = SR.HashIndexGroupTitle, - ComponentProperties = new InputBoxProperties() - { - Title = SR.IndexBucketCountPropertyTitle, - Width = 200 - } - }, - new DesignerDataPropertyInfo() { PropertyName = IndexPropertyNames.IncludedColumns, Description = SR.IndexIncludedColumnsPropertyDescription, @@ -1403,6 +1380,34 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner } } }); + + if (tableDesigner.TableViewModel.IsMemoryOptimized || tableDesigner.TableViewModel.Indexes.Items.Any(idx => idx.IsHash)) + { + view.IndexTableOptions.AdditionalProperties.AddRange(new DesignerDataPropertyInfo[] { + new DesignerDataPropertyInfo() + { + PropertyName = IndexPropertyNames.IsHash, + Description = SR.IndexIsHashPropertyDescription, + ComponentType = DesignerComponentType.Checkbox, + ComponentProperties = new CheckBoxProperties() + { + Title = SR.IndexIsHashPropertyTitle + } + }, + new DesignerDataPropertyInfo() + { + PropertyName = IndexPropertyNames.BucketCount, + Description = SR.IndexBucketCountPropertyDescription, + ComponentType = DesignerComponentType.Input, + ComponentProperties = new InputBoxProperties() + { + Title = SR.IndexBucketCountPropertyTitle, + Width = 200 + } + }, + }); + } + view.IndexTableOptions.PropertiesToDisplay = new List() { IndexPropertyNames.Name, IndexPropertyNames.ColumnsDisplayValue, IndexPropertyNames.IsClustered, IndexPropertyNames.IsUnique }; view.IndexTableOptions.CanAddRows = true; view.IndexTableOptions.CanRemoveRows = true;