From 4861d7a174b147bb488bf8c098afcb9816ed194d Mon Sep 17 00:00:00 2001 From: Leila Lali Date: Wed, 24 May 2017 12:07:41 -0700 Subject: [PATCH] Fixed the issue with parsing sql server 2017 version (#357) * Fixed the issue with parsing sql server 2017 --- .../ObjectExplorer/Nodes/SqlServerType.cs | 5 + .../ObjectExplorer/Nodes/ValidForFlag.cs | 14 +- .../ObjectExplorer/SmoModel/SmoQuerier.cs | 13 + .../ObjectExplorer/SmoModel/SmoQueryModel.cs | 585 ++---------------- .../ObjectExplorer/SmoModel/SmoQueryModel.tt | 13 +- .../SmoModel/TreeNodeDefinition.xml | 104 ++-- .../SmoModel/TreeNodeGenerator.cs | 44 +- .../SmoModel/TreeNodeGenerator.tt | 19 +- 8 files changed, 170 insertions(+), 627 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/SqlServerType.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/SqlServerType.cs index 7b7f7eaf..d15dc4ec 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/SqlServerType.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/SqlServerType.cs @@ -19,6 +19,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes Sql2012, Sql2014, Sql2016, + Sql2017, Azure, AzureV12 } @@ -83,6 +84,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes { serverType = SqlServerType.Sql2016; } + else if (serverVersion.StartsWith("14", StringComparison.Ordinal)) + { + serverType = SqlServerType.Sql2017; + } } return serverType; diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs index 8b10051b..32e5648a 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ValidForFlag.cs @@ -16,13 +16,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes Sql2012 = 0x04, Sql2014 = 0x08, Azure = 0x10, - NotDebugInstance = 0x20, - NotContainedUser = 0x40, - AzureV12 = 0x80, - Sql2016 = 0x100, - CanConnectToMaster = 0x200, - CanViewSecurity = 0x400, - SqlvNext = 0x800, - All = Sql2005 | Sql2008 | Sql2012 | Sql2014 | Sql2016 | SqlvNext | Azure | AzureV12 + AzureV12 = 0x20, + Sql2016 = 0x40, + Sql2017 = 0x80, + AllOnPrem = Sql2005 | Sql2008 | Sql2012 | Sql2014 | Sql2016 | Sql2017, + AllAzure = Azure | AzureV12, + All = Sql2005 | Sql2008 | Sql2012 | Sql2014 | Sql2016 | Sql2017 | Azure | AzureV12 } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs index 05d64440..d4da5699 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Globalization; +using System.Linq; using Microsoft.Data.Tools.DataSets; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; @@ -142,6 +143,18 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel return null; } + + protected IEnumerable GetSmoCollectionResult(HashSet urns, SmoCollectionBase retValue, SqlSmoObject parent) where T : SqlSmoObject + { + if (urns != null) + { + return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parent, c) && urns.Contains(c.Urn)); + } + else + { + return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parent, c)); + } + } } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs index 41665437..a13f6b24 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs @@ -37,14 +37,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "Database"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -76,14 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "LinkedServer"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -115,14 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "Login"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -154,14 +133,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "ServerRole"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -193,14 +165,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "Credential"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -232,14 +197,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "CryptographicProvider"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -271,14 +229,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "Audit"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -310,14 +261,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "ServerAuditSpecification"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -349,14 +293,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "Endpoint"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -388,14 +325,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "LinkedServer"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -427,14 +357,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "ServerDdlTrigger"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -466,14 +389,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServer, filter, "UserDefinedMessage"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServer, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServer); } } return Enumerable.Empty(); @@ -505,14 +421,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "Table"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper
(retValue); - } + return GetSmoCollectionResult
(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -544,14 +453,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTable.Parent, filter, "Table"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper
(retValue).Where(c => PassesFinalFilters(parentTable, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper
(retValue); - } + return GetSmoCollectionResult
(urns, retValue, parentTable); } } return Enumerable.Empty(); @@ -583,14 +485,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "View"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -622,14 +517,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "Synonym"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -661,14 +549,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTableViewTableTypeBase, filter, "Column"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentTableViewTableTypeBase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentTableViewTableTypeBase); } } return Enumerable.Empty(); @@ -700,14 +581,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTableViewTableTypeBase, filter, "Index"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentTableViewTableTypeBase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentTableViewTableTypeBase); } } return Enumerable.Empty(); @@ -739,14 +613,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTable, filter, "Check"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentTable, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentTable); } } return Enumerable.Empty(); @@ -778,14 +645,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTable, filter, "ForeignKey"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentTable, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentTable); } } return Enumerable.Empty(); @@ -844,14 +704,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTable, filter, "Trigger"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentTable, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentTable); } } return Enumerable.Empty(); @@ -910,14 +763,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentTableViewBase, filter, "Statistic"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentTableViewBase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentTableViewBase); } } return Enumerable.Empty(); @@ -949,14 +795,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "DatabaseDdlTrigger"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -988,14 +827,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "SqlAssembly"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1027,14 +859,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "Sequence"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1066,14 +891,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "UserDefinedDataType"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1105,14 +923,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "UserDefinedTableType"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1144,14 +955,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "XmlSchemaCollection"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1183,14 +987,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "UserDefinedType"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1222,14 +1019,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "UserDefinedFunction"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1261,14 +1051,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "UserDefinedAggregate"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1300,14 +1083,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "FileGroup"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1339,14 +1115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentFileGroup, filter, "DataFile"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentFileGroup, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentFileGroup); } } return Enumerable.Empty(); @@ -1378,14 +1147,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "FullTextCatalog"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1417,14 +1179,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "FullTextStopList"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1456,14 +1211,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "PartitionFunction"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1495,14 +1243,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "PartitionScheme"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1534,14 +1275,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "SearchPropertyList"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1573,14 +1307,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "User"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1612,14 +1339,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "Schema"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1651,14 +1371,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "AsymmetricKey"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1690,14 +1403,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "Certificate"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1729,14 +1435,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "SymmetricKey"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1822,14 +1521,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "DatabaseAuditSpecification"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1861,14 +1553,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "SecurityPolicy"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1900,14 +1585,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "DatabaseScopedCredential"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1939,14 +1617,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "DatabaseRole"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -1978,14 +1649,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "ApplicationRole"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2017,14 +1681,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "ColumnMasterKey"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2056,14 +1713,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "ColumnEncryptionKey"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2122,14 +1772,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServiceBroker, filter, "BrokerService"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServiceBroker); } } return Enumerable.Empty(); @@ -2161,14 +1804,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServiceBroker, filter, "ServiceContract"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServiceBroker); } } return Enumerable.Empty(); @@ -2200,14 +1836,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServiceBroker, filter, "ServiceQueue"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServiceBroker); } } return Enumerable.Empty(); @@ -2239,14 +1868,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServiceBroker, filter, "RemoteServiceBinding"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServiceBroker); } } return Enumerable.Empty(); @@ -2278,14 +1900,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServiceBroker, filter, "BrokerPriority"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServiceBroker); } } return Enumerable.Empty(); @@ -2317,14 +1932,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentServiceBroker, filter, "MessageType"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentServiceBroker, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentServiceBroker); } } return Enumerable.Empty(); @@ -2356,14 +1964,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "ExternalDataSource"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2395,14 +1996,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "ExternalFileFormat"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2434,14 +2028,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "StoredProcedure"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2473,14 +2060,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase, filter, "ExtendedStoredProcedure"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); @@ -2512,14 +2092,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentStoredProcedure, filter, "Parameter"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentStoredProcedure, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentStoredProcedure); } } UserDefinedAggregate parentUserDefinedAggregate = context.Parent as UserDefinedAggregate; @@ -2538,14 +2111,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentUserDefinedAggregate, filter, "Parameter"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentUserDefinedAggregate, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentUserDefinedAggregate); } } UserDefinedFunction parentUserDefinedFunction = context.Parent as UserDefinedFunction; @@ -2564,14 +2130,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentUserDefinedFunction, filter, "Parameter"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentUserDefinedFunction, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentUserDefinedFunction); } } return Enumerable.Empty(); @@ -2603,14 +2162,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentPartitionFunction, filter, "PartitionFunctionParameter"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentPartitionFunction, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentPartitionFunction); } } return Enumerable.Empty(); @@ -2642,14 +2194,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { urns = GetUrns(context, parentDatabase.Parent, filter, "SystemDataType"); } - if (hasFilter && urns != null) - { - return new SmoCollectionWrapper(retValue).Where(c => PassesFinalFilters(parentDatabase, c) && urns.Contains(c.Urn)); - } - else - { - return new SmoCollectionWrapper(retValue); - } + return GetSmoCollectionResult(urns, retValue, parentDatabase); } } return Enumerable.Empty(); diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt index ccda2a28..5231bd36 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt @@ -97,18 +97,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel WriteLine(string.Format("urns = GetUrns(context, {0}, filter, \"{1}\");", fieldForUrn, nodeType)); PopIndent(); WriteLine("}"); - WriteLine("if (hasFilter && urns != null)"); - WriteLine("{"); - PushIndent(indent); - WriteLine(string.Format("return new SmoCollectionWrapper<{0}>(retValue).Where(c => PassesFinalFilters({1}, c) && urns.Contains(c.Urn));", nodeType, parentVar)); - PopIndent(); - WriteLine("}"); - WriteLine("else"); - WriteLine("{"); - PushIndent(indent); - WriteLine(string.Format("return new SmoCollectionWrapper<{0}>(retValue);", nodeType)); - PopIndent(); - WriteLine("}"); + WriteLine(string.Format("return GetSmoCollectionResult<{0}>(urns, retValue, {1});", nodeType, parentVar)); } else { diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml index 01c670b4..419e03e8 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml @@ -11,7 +11,7 @@ - + @@ -23,7 +23,7 @@ --> - + @@ -33,25 +33,25 @@ --> - + - + - - - - - + + + + + - + @@ -70,7 +70,7 @@ - + TableTemporalType.None TableTemporalType.SystemVersioned @@ -102,12 +102,12 @@ --> - + - + @@ -118,7 +118,7 @@ - + @@ -150,12 +150,12 @@ - + TableTemporalType.HistoryTable @@ -177,7 +177,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -193,7 +193,7 @@ - + IndexKeyType.DriPrimaryKey IndexKeyType.DriUniqueKey @@ -203,7 +203,7 @@ - + IndexKeyType.None @@ -236,7 +236,7 @@ - + @@ -245,10 +245,10 @@ - + @@ -262,9 +262,9 @@ - - - + + + @@ -274,7 +274,7 @@ - + IndexKeyType.DriPrimaryKey IndexKeyType.DriUniqueKey @@ -289,12 +289,12 @@ - - + + - - + + @@ -336,7 +336,7 @@ - + UserDefinedFunctionType.Scalar @@ -355,7 +355,7 @@ - + @@ -370,15 +370,15 @@ --> - + - + - + @@ -393,27 +393,27 @@ - - - - - + + + + + - - - - + + + + - - - + + + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs index 96692049..ada45364 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs @@ -160,7 +160,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelSecurity, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12|ValidForFlag.NotContainedUser|ValidForFlag.CanViewSecurity, + ValidFor = ValidForFlag.All, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -168,7 +168,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerObjects, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotContainedUser, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -202,7 +202,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.SystemDatabases, IsSystemObject = true, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12|ValidForFlag.NotContainedUser|ValidForFlag.CanConnectToMaster, + ValidFor = ValidForFlag.All, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -236,7 +236,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelLinkedServerLogins, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -251,7 +251,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerRoles, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -259,7 +259,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelCredentials, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -267,7 +267,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelCryptographicProviders, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotDebugInstance, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -275,7 +275,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerAudits, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -283,7 +283,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerAuditSpecifications, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -310,7 +310,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelEndpoints, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -695,7 +695,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ServiceBroker, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -703,7 +703,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.Storage, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.AzureV12|ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -899,7 +899,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.Assemblies, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.AzureV12|ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -1129,7 +1129,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.AsymmetricKeys, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -1137,7 +1137,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.Certificates, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -1145,7 +1145,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.SymmetricKeys, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -1169,7 +1169,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.MasterKeys, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, + ValidFor = ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -1742,7 +1742,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.AggregateFunctions, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.AzureV12|ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -1878,7 +1878,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedTypes, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.AzureV12|ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -1886,7 +1886,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.XmlSchemaCollections, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.AzureV12|ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -1986,7 +1986,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.SystemClrDataTypes, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.All, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { @@ -3345,7 +3345,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeType = "Folder", NodeTypeId = NodeTypes.ApplicationRoles, IsSystemObject = false, - ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, + ValidFor = ValidForFlag.AzureV12|ValidForFlag.AllOnPrem, SortPriority = SmoTreeNode.NextSortPriority, }); } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt index 759b1c4b..2242c61c 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt @@ -344,24 +344,17 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel flags.Add("ValidForFlag.AzureV12"); } - if (validForStr.Contains("NotDebugInstance")) + if (validForStr.Contains("AllOnPrem")) { - flags.Add("ValidForFlag.NotDebugInstance"); + flags.Add("ValidForFlag.AllOnPrem"); } - - if (validForStr.Contains("NotContainedUser")) + if (validForStr.Contains("AllAzure")) { - flags.Add("ValidForFlag.NotContainedUser"); + flags.Add("ValidForFlag.AllAzure"); } - - if (validForStr.Contains("CanConnectToMaster")) + if (validForStr == "All") { - flags.Add("ValidForFlag.CanConnectToMaster"); - } - - if (validForStr.Contains("CanViewSecurity")) - { - flags.Add("ValidForFlag.CanViewSecurity"); + flags.Add("ValidForFlag.All"); } return string.Join("|", flags);