diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs index 8b26cefa..bff8cd9c 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/ChildFactory.cs @@ -26,9 +26,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes /// /// Expands an element in the /// - /// + /// Parent Node + /// force to refresh + /// name of the sql object to filter /// - public abstract IEnumerable Expand(TreeNode parent, bool refresh); + public abstract IEnumerable Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects); /// /// The list of filters that should be applied on the smo object list diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeFilter.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeFilter.cs index cfaea0c3..255e60b2 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeFilter.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeFilter.cs @@ -69,13 +69,18 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes for (int i = 0; i < values.Count; i++) { var value = values[i]; - object proeprtyValue = value; + object propertyValue = value; + if (Type == typeof(string)) + { + propertyValue = $"'{propertyValue}'"; + } if (Type == typeof(Enum)) { - proeprtyValue = (int)Convert.ChangeType(value, Type); + propertyValue = (int)Convert.ChangeType(value, Type); + } string orPrefix = i == 0 ? string.Empty : "or"; - filter = $"{filter} {orPrefix} @{Property} = {proeprtyValue}"; + filter = $"{filter} {orPrefix} @{Property} = {propertyValue}"; } } filter = $"({filter})"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs index 2f089dd7..6ce03318 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs @@ -44,6 +44,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes ServerLevelServerTriggers, ServerLevelLinkedServers, ServerLevelEndpoints, + SystemScalarValuedFunctions, + SystemTableValuedFunctions, + SystemFunctions, DacInstancesFolder, Tables, Views, diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs index df4f172a..b00cde92 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/TreeNode.cs @@ -62,6 +62,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes /// public string NodeType { get; set; } + /// + // True if the node includes system object + /// + public bool IsSystemObject { get; set; } + /// /// Enum defining the type of the node - for example Server, Database, Folder, Table /// @@ -196,17 +201,26 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes /// Expands this node and returns its children /// /// Children as an IList. This is the raw children collection, not a copy - public IList Expand() + public IList Expand(string name= null) { // TODO consider why solution explorer has separate Children and Items options if (children.IsInitialized) { return children; } - PopulateChildren(false); + PopulateChildren(false, name); return children; } + /// + /// Expands this node and returns its children + /// + /// Children as an IList. This is the raw children collection, not a copy + public IList Expand() + { + return Expand(null); + } + /// /// Refresh this node and returns its children /// @@ -214,7 +228,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes public virtual IList Refresh() { // TODO consider why solution explorer has separate Children and Items options - PopulateChildren(true); + PopulateChildren(true, null); return children; } @@ -266,13 +280,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes return Parent as T; } - protected void PopulateChildren(bool refresh) + protected void PopulateChildren(bool refresh, string name = null) { + Logger.Write(LogLevel.Verbose, string.Format(CultureInfo.InvariantCulture, "Populating oe node :{0}", this.GetNodePath())); Debug.Assert(IsAlwaysLeaf == false); SmoQueryContext context = this.GetContextAs(); + bool includeSystemObjects = context != null && context.Database != null ? ObjectExplorerUtils.IsSystemDatabaseConnection(context.Database.Name) : true; + - if (children.IsPopulating || context == null) + if (children.IsPopulating || context == null) return; children.Clear(); @@ -285,7 +302,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes { foreach (var factory in childFactories) { - IEnumerable items = factory.Expand(this, refresh); + IEnumerable items = factory.Expand(this, refresh, name, includeSystemObjects); if (items != null) { foreach (TreeNode item in items) @@ -300,7 +317,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes } catch(Exception ex) { - Logger.Write(LogLevel.Error, $"Failed populating oe children. error:{ex.Message} {ex.StackTrace}"); + string error = string.Format(CultureInfo.InvariantCulture, "Failed populating oe children. error:{0} inner:{1} stacktrace:{2}", + ex.Message, ex.InnerException != null ? ex.InnerException.Message : "", ex.StackTrace); + Logger.Write(LogLevel.Error, error); } finally { diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs index 2c3755ee..7497add6 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs @@ -437,7 +437,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer this.serviceProvider = serviceProvider; this.connectionService = connectionService; } - + public string Uri { get; private set; } public TreeNode Root { get; private set; } @@ -450,7 +450,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer // Assuming the databases are in a folder under server node var children = rootNode.Expand(); var databasesRoot = children.FirstOrDefault(x => x.NodeTypeId == NodeTypes.Databases); - var databasesChildren = databasesRoot.Expand(); + var databasesChildren = databasesRoot.Expand(response.ConnectionSummary.DatabaseName); var databases = databasesChildren.Where(x => x.NodeType == NodeTypes.Database.ToString()); var databaseNode = databases.FirstOrDefault(d => d.Label == response.ConnectionSummary.DatabaseName); databaseNode.Label = rootNode.Label; diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs index d2b460f9..d22c5720 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoChildFactoryBase.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using System.Reflection; using Microsoft.SqlServer.Management.Smo; @@ -21,20 +22,26 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel return null; } - public override IEnumerable Expand(TreeNode parent, bool refresh) + public override IEnumerable Expand(TreeNode parent, bool refresh, string name, bool includeSystemObjects) { List allChildren = new List(); try { OnExpandPopulateFolders(allChildren, parent); + if(!includeSystemObjects) + { + allChildren.RemoveAll(x => x.IsSystemObject); + } RemoveFoldersFromInvalidSqlServerVersions(allChildren, parent); - OnExpandPopulateNonFolders(allChildren, parent, refresh); + OnExpandPopulateNonFolders(allChildren, parent, refresh, name); OnBeginAsyncOperations(parent); } catch(Exception ex) { - Logger.Write(LogLevel.Error, $"Failed expanding oe children. error:{ex.Message} {ex.StackTrace}"); + string error = string.Format(CultureInfo.InvariantCulture, "Failed expanding oe children. parent:{0} error:{1} inner:{2} stacktrace:{3}", + parent != null ? parent.GetNodePath() : "", ex.Message, ex.InnerException != null ? ex.InnerException.Message : "", ex.StackTrace); + Logger.Write(LogLevel.Error, error); } finally { @@ -56,8 +63,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel /// /// List to which nodes should be added /// Parent the nodes are being added to - protected virtual void OnExpandPopulateNonFolders(IList allChildren, TreeNode parent, bool refresh) + protected virtual void OnExpandPopulateNonFolders(IList allChildren, TreeNode parent, bool refresh, string name) { + Logger.Write(LogLevel.Verbose, string.Format(CultureInfo.InvariantCulture, "child factory parent :{0}", parent.GetNodePath())); + if (ChildQuerierTypes == null) { // This node does not support non-folder children @@ -73,22 +82,40 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel } IEnumerable queriers = context.ServiceProvider.GetServices(q => IsCompatibleQuerier(q)); - var filters = this.Filters; + var filters = this.Filters.ToList(); + if (!string.IsNullOrEmpty(name)) + { + filters.Add(new NodeFilter + { + Property = "Name", + Type = typeof(string), + Values = new List { name }, + }); + } foreach (var querier in queriers) { string propertyFilter = GetProperyFilter(filters, querier.GetType(), validForFlag); - - foreach (var smoObject in querier.Query(context, propertyFilter, refresh)) + try { - if (smoObject == null) + foreach (var smoObject in querier.Query(context, propertyFilter, refresh)) { - Console.WriteLine("smoObject should not be null"); - } - TreeNode childNode = CreateChild(parent, smoObject); - if (childNode != null && PassesFinalFilters(childNode, smoObject) && !ShouldFilterNode(childNode, validForFlag)) - { - allChildren.Add(childNode); + if (smoObject == null) + { + Logger.Write(LogLevel.Error, "smoObject should not be null"); + } + TreeNode childNode = CreateChild(parent, smoObject); + if (childNode != null && PassesFinalFilters(childNode, smoObject) && !ShouldFilterNode(childNode, validForFlag)) + { + allChildren.Add(childNode); + } } + + } + catch (Exception ex) + { + string error = string.Format(CultureInfo.InvariantCulture, "Failed getting smo objects. parent:{0} querier: {1} error:{2} inner:{3} stacktrace:{4}", + parent != null ? parent.GetNodePath() : "", querier.GetType(), ex.Message, ex.InnerException != null ? ex.InnerException.Message : "", ex.StackTrace); + Logger.Write(LogLevel.Error, error); } } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs index 3fdc3900..79004da3 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQuerier.cs @@ -6,10 +6,13 @@ using System; using System.Collections.Generic; using System.Data; +using System.Globalization; using Microsoft.Data.Tools.DataSets; +using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlTools.Extensibility; +using Microsoft.SqlTools.Utility; namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { @@ -74,12 +77,42 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel return true; } + protected HashSet GetUrns(SmoQueryContext context, SqlSmoObject smoObject, string filter, string objectName) + { + HashSet urns = null; + string urn = string.Empty; + try + { + string parentUrn = smoObject.Urn; + urn = parentUrn != null ? $"{parentUrn.ToString()}/{objectName}" + filter : string.Empty; + + if (!string.IsNullOrEmpty(urn)) + { + Enumerator en = new Enumerator(); + Request request = new Request(new Urn(urn)); + ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); + + EnumResult result = en.Process(serverConnection, request); + + urns = GetUrns(result); + } + } + catch (Exception ex) + { + string error = string.Format(CultureInfo.InvariantCulture, "Failed getting urns. error:{0} inner:{1} stacktrace:{2}", + ex.Message, ex.InnerException != null ? ex.InnerException.Message : "", ex.StackTrace); + Logger.Write(LogLevel.Error, error); + } + + return urns; + } + /// /// Gets the urn from the enumResult /// protected HashSet GetUrns(EnumResult enumResult) { - lock (lockObject) + try { HashSet urns = null; if (enumResult != null && enumResult.Data != null) @@ -99,6 +132,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel return urns; } + catch(Exception ex) + { + string error = string.Format(CultureInfo.InvariantCulture, "Failed getting urns. error:{0} inner:{1} stacktrace:{2}", + ex.Message, ex.InnerException != null ? ex.InnerException.Message : "", ex.StackTrace); + Logger.Write(LogLevel.Error, error); + } + + return null; } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs index cb1482fb..41665437 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.cs @@ -6,8 +6,6 @@ using System; using System.Collections.Generic; using System.Composition; using System.Linq; -using Microsoft.SqlServer.Management.Common; -using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo.Broker; @@ -29,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Databases.Refresh(); + parentServer.Databases.Refresh(true); } var retValue = parentServer.Databases; if (retValue != null) @@ -37,12 +35,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/Database" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "Database"); } if (hasFilter && urns != null) { @@ -73,7 +66,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.LinkedServers.Refresh(); + parentServer.LinkedServers.Refresh(true); } var retValue = parentServer.LinkedServers; if (retValue != null) @@ -81,12 +74,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/LinkedServer" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "LinkedServer"); } if (hasFilter && urns != null) { @@ -117,7 +105,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Logins.Refresh(); + parentServer.Logins.Refresh(true); } var retValue = parentServer.Logins; if (retValue != null) @@ -125,12 +113,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/Login" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "Login"); } if (hasFilter && urns != null) { @@ -161,7 +144,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Roles.Refresh(); + parentServer.Roles.Refresh(true); } var retValue = parentServer.Roles; if (retValue != null) @@ -169,12 +152,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/ServerRole" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "ServerRole"); } if (hasFilter && urns != null) { @@ -205,7 +183,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Credentials.Refresh(); + parentServer.Credentials.Refresh(true); } var retValue = parentServer.Credentials; if (retValue != null) @@ -213,12 +191,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/Credential" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "Credential"); } if (hasFilter && urns != null) { @@ -249,7 +222,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.CryptographicProviders.Refresh(); + parentServer.CryptographicProviders.Refresh(true); } var retValue = parentServer.CryptographicProviders; if (retValue != null) @@ -257,12 +230,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/CryptographicProvider" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "CryptographicProvider"); } if (hasFilter && urns != null) { @@ -293,7 +261,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Audits.Refresh(); + parentServer.Audits.Refresh(true); } var retValue = parentServer.Audits; if (retValue != null) @@ -301,12 +269,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/Audit" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "Audit"); } if (hasFilter && urns != null) { @@ -337,7 +300,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.ServerAuditSpecifications.Refresh(); + parentServer.ServerAuditSpecifications.Refresh(true); } var retValue = parentServer.ServerAuditSpecifications; if (retValue != null) @@ -345,12 +308,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/ServerAuditSpecification" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "ServerAuditSpecification"); } if (hasFilter && urns != null) { @@ -381,7 +339,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Endpoints.Refresh(); + parentServer.Endpoints.Refresh(true); } var retValue = parentServer.Endpoints; if (retValue != null) @@ -389,12 +347,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/Endpoint" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "Endpoint"); } if (hasFilter && urns != null) { @@ -425,7 +378,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.LinkedServers.Refresh(); + parentServer.LinkedServers.Refresh(true); } var retValue = parentServer.LinkedServers; if (retValue != null) @@ -433,12 +386,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/LinkedServer" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "LinkedServer"); } if (hasFilter && urns != null) { @@ -469,7 +417,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.Triggers.Refresh(); + parentServer.Triggers.Refresh(true); } var retValue = parentServer.Triggers; if (retValue != null) @@ -477,12 +425,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/ServerDdlTrigger" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "ServerDdlTrigger"); } if (hasFilter && urns != null) { @@ -513,7 +456,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServer.UserDefinedMessages.Refresh(); + parentServer.UserDefinedMessages.Refresh(true); } var retValue = parentServer.UserDefinedMessages; if (retValue != null) @@ -521,12 +464,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServer.Urn.ToString()}/UserDefinedMessage" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServer, filter, "UserDefinedMessage"); } if (hasFilter && urns != null) { @@ -557,7 +495,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Tables.Refresh(); + parentDatabase.Tables.Refresh(true); } var retValue = parentDatabase.Tables; if (retValue != null) @@ -565,12 +503,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/Table" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "Table"); } if (hasFilter && urns != null) { @@ -601,7 +534,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTable.Parent.Tables.Refresh(); + parentTable.Parent.Tables.Refresh(true); } var retValue = parentTable.Parent.Tables; if (retValue != null) @@ -609,12 +542,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTable.Parent.Urn.ToString()}/Table" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTable.Parent, filter, "Table"); } if (hasFilter && urns != null) { @@ -645,7 +573,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Views.Refresh(); + parentDatabase.Views.Refresh(true); } var retValue = parentDatabase.Views; if (retValue != null) @@ -653,12 +581,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/View" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "View"); } if (hasFilter && urns != null) { @@ -689,7 +612,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Synonyms.Refresh(); + parentDatabase.Synonyms.Refresh(true); } var retValue = parentDatabase.Synonyms; if (retValue != null) @@ -697,12 +620,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/Synonym" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "Synonym"); } if (hasFilter && urns != null) { @@ -733,7 +651,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTableViewTableTypeBase.Columns.Refresh(); + parentTableViewTableTypeBase.Columns.Refresh(true); } var retValue = parentTableViewTableTypeBase.Columns; if (retValue != null) @@ -741,12 +659,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTableViewTableTypeBase.Urn.ToString()}/Column" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTableViewTableTypeBase, filter, "Column"); } if (hasFilter && urns != null) { @@ -777,7 +690,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTableViewTableTypeBase.Indexes.Refresh(); + parentTableViewTableTypeBase.Indexes.Refresh(true); } var retValue = parentTableViewTableTypeBase.Indexes; if (retValue != null) @@ -785,12 +698,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTableViewTableTypeBase.Urn.ToString()}/Index" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTableViewTableTypeBase, filter, "Index"); } if (hasFilter && urns != null) { @@ -821,7 +729,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTable.Checks.Refresh(); + parentTable.Checks.Refresh(true); } var retValue = parentTable.Checks; if (retValue != null) @@ -829,12 +737,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTable.Urn.ToString()}/Check" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTable, filter, "Check"); } if (hasFilter && urns != null) { @@ -865,7 +768,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTable.ForeignKeys.Refresh(); + parentTable.ForeignKeys.Refresh(true); } var retValue = parentTable.ForeignKeys; if (retValue != null) @@ -873,12 +776,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTable.Urn.ToString()}/ForeignKey" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTable, filter, "ForeignKey"); } if (hasFilter && urns != null) { @@ -936,7 +834,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTable.Triggers.Refresh(); + parentTable.Triggers.Refresh(true); } var retValue = parentTable.Triggers; if (retValue != null) @@ -944,12 +842,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTable.Urn.ToString()}/Trigger" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTable, filter, "Trigger"); } if (hasFilter && urns != null) { @@ -1007,7 +900,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentTableViewBase.Statistics.Refresh(); + parentTableViewBase.Statistics.Refresh(true); } var retValue = parentTableViewBase.Statistics; if (retValue != null) @@ -1015,12 +908,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentTableViewBase.Urn.ToString()}/Statistic" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentTableViewBase, filter, "Statistic"); } if (hasFilter && urns != null) { @@ -1051,7 +939,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Triggers.Refresh(); + parentDatabase.Triggers.Refresh(true); } var retValue = parentDatabase.Triggers; if (retValue != null) @@ -1059,12 +947,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/DatabaseDdlTrigger" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "DatabaseDdlTrigger"); } if (hasFilter && urns != null) { @@ -1095,7 +978,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Assemblies.Refresh(); + parentDatabase.Assemblies.Refresh(true); } var retValue = parentDatabase.Assemblies; if (retValue != null) @@ -1103,12 +986,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/SqlAssembly" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "SqlAssembly"); } if (hasFilter && urns != null) { @@ -1139,7 +1017,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Sequences.Refresh(); + parentDatabase.Sequences.Refresh(true); } var retValue = parentDatabase.Sequences; if (retValue != null) @@ -1147,12 +1025,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/Sequence" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "Sequence"); } if (hasFilter && urns != null) { @@ -1183,7 +1056,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.UserDefinedDataTypes.Refresh(); + parentDatabase.UserDefinedDataTypes.Refresh(true); } var retValue = parentDatabase.UserDefinedDataTypes; if (retValue != null) @@ -1191,12 +1064,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/UserDefinedDataType" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "UserDefinedDataType"); } if (hasFilter && urns != null) { @@ -1227,7 +1095,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.UserDefinedTableTypes.Refresh(); + parentDatabase.UserDefinedTableTypes.Refresh(true); } var retValue = parentDatabase.UserDefinedTableTypes; if (retValue != null) @@ -1235,12 +1103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/UserDefinedTableType" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "UserDefinedTableType"); } if (hasFilter && urns != null) { @@ -1271,7 +1134,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.XmlSchemaCollections.Refresh(); + parentDatabase.XmlSchemaCollections.Refresh(true); } var retValue = parentDatabase.XmlSchemaCollections; if (retValue != null) @@ -1279,12 +1142,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/XmlSchemaCollection" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "XmlSchemaCollection"); } if (hasFilter && urns != null) { @@ -1315,7 +1173,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.UserDefinedTypes.Refresh(); + parentDatabase.UserDefinedTypes.Refresh(true); } var retValue = parentDatabase.UserDefinedTypes; if (retValue != null) @@ -1323,12 +1181,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/UserDefinedType" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "UserDefinedType"); } if (hasFilter && urns != null) { @@ -1359,7 +1212,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.UserDefinedFunctions.Refresh(); + parentDatabase.UserDefinedFunctions.Refresh(true); } var retValue = parentDatabase.UserDefinedFunctions; if (retValue != null) @@ -1367,12 +1220,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/UserDefinedFunction" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "UserDefinedFunction"); } if (hasFilter && urns != null) { @@ -1403,7 +1251,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.UserDefinedAggregates.Refresh(); + parentDatabase.UserDefinedAggregates.Refresh(true); } var retValue = parentDatabase.UserDefinedAggregates; if (retValue != null) @@ -1411,12 +1259,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/UserDefinedAggregate" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "UserDefinedAggregate"); } if (hasFilter && urns != null) { @@ -1447,7 +1290,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.FileGroups.Refresh(); + parentDatabase.FileGroups.Refresh(true); } var retValue = parentDatabase.FileGroups; if (retValue != null) @@ -1455,12 +1298,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/FileGroup" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "FileGroup"); } if (hasFilter && urns != null) { @@ -1491,7 +1329,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentFileGroup.Files.Refresh(); + parentFileGroup.Files.Refresh(true); } var retValue = parentFileGroup.Files; if (retValue != null) @@ -1499,12 +1337,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentFileGroup.Urn.ToString()}/DataFile" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentFileGroup, filter, "DataFile"); } if (hasFilter && urns != null) { @@ -1535,7 +1368,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.FullTextCatalogs.Refresh(); + parentDatabase.FullTextCatalogs.Refresh(true); } var retValue = parentDatabase.FullTextCatalogs; if (retValue != null) @@ -1543,12 +1376,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/FullTextCatalog" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "FullTextCatalog"); } if (hasFilter && urns != null) { @@ -1579,7 +1407,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.FullTextStopLists.Refresh(); + parentDatabase.FullTextStopLists.Refresh(true); } var retValue = parentDatabase.FullTextStopLists; if (retValue != null) @@ -1587,12 +1415,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/FullTextStopList" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "FullTextStopList"); } if (hasFilter && urns != null) { @@ -1623,7 +1446,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.PartitionFunctions.Refresh(); + parentDatabase.PartitionFunctions.Refresh(true); } var retValue = parentDatabase.PartitionFunctions; if (retValue != null) @@ -1631,12 +1454,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/PartitionFunction" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "PartitionFunction"); } if (hasFilter && urns != null) { @@ -1667,7 +1485,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.PartitionSchemes.Refresh(); + parentDatabase.PartitionSchemes.Refresh(true); } var retValue = parentDatabase.PartitionSchemes; if (retValue != null) @@ -1675,12 +1493,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/PartitionScheme" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "PartitionScheme"); } if (hasFilter && urns != null) { @@ -1711,7 +1524,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.SearchPropertyLists.Refresh(); + parentDatabase.SearchPropertyLists.Refresh(true); } var retValue = parentDatabase.SearchPropertyLists; if (retValue != null) @@ -1719,12 +1532,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/SearchPropertyList" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "SearchPropertyList"); } if (hasFilter && urns != null) { @@ -1755,7 +1563,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Users.Refresh(); + parentDatabase.Users.Refresh(true); } var retValue = parentDatabase.Users; if (retValue != null) @@ -1763,12 +1571,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/User" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "User"); } if (hasFilter && urns != null) { @@ -1799,7 +1602,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Schemas.Refresh(); + parentDatabase.Schemas.Refresh(true); } var retValue = parentDatabase.Schemas; if (retValue != null) @@ -1807,12 +1610,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/Schema" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "Schema"); } if (hasFilter && urns != null) { @@ -1843,7 +1641,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.AsymmetricKeys.Refresh(); + parentDatabase.AsymmetricKeys.Refresh(true); } var retValue = parentDatabase.AsymmetricKeys; if (retValue != null) @@ -1851,12 +1649,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/AsymmetricKey" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "AsymmetricKey"); } if (hasFilter && urns != null) { @@ -1887,7 +1680,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Certificates.Refresh(); + parentDatabase.Certificates.Refresh(true); } var retValue = parentDatabase.Certificates; if (retValue != null) @@ -1895,12 +1688,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/Certificate" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "Certificate"); } if (hasFilter && urns != null) { @@ -1931,7 +1719,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.SymmetricKeys.Refresh(); + parentDatabase.SymmetricKeys.Refresh(true); } var retValue = parentDatabase.SymmetricKeys; if (retValue != null) @@ -1939,12 +1727,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/SymmetricKey" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "SymmetricKey"); } if (hasFilter && urns != null) { @@ -2029,7 +1812,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.DatabaseAuditSpecifications.Refresh(); + parentDatabase.DatabaseAuditSpecifications.Refresh(true); } var retValue = parentDatabase.DatabaseAuditSpecifications; if (retValue != null) @@ -2037,12 +1820,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/DatabaseAuditSpecification" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "DatabaseAuditSpecification"); } if (hasFilter && urns != null) { @@ -2073,7 +1851,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.SecurityPolicies.Refresh(); + parentDatabase.SecurityPolicies.Refresh(true); } var retValue = parentDatabase.SecurityPolicies; if (retValue != null) @@ -2081,12 +1859,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/SecurityPolicy" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "SecurityPolicy"); } if (hasFilter && urns != null) { @@ -2117,7 +1890,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.DatabaseScopedCredentials.Refresh(); + parentDatabase.DatabaseScopedCredentials.Refresh(true); } var retValue = parentDatabase.DatabaseScopedCredentials; if (retValue != null) @@ -2125,12 +1898,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/DatabaseScopedCredential" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "DatabaseScopedCredential"); } if (hasFilter && urns != null) { @@ -2161,7 +1929,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Roles.Refresh(); + parentDatabase.Roles.Refresh(true); } var retValue = parentDatabase.Roles; if (retValue != null) @@ -2169,12 +1937,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/DatabaseRole" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "DatabaseRole"); } if (hasFilter && urns != null) { @@ -2205,7 +1968,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.ApplicationRoles.Refresh(); + parentDatabase.ApplicationRoles.Refresh(true); } var retValue = parentDatabase.ApplicationRoles; if (retValue != null) @@ -2213,12 +1976,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/ApplicationRole" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "ApplicationRole"); } if (hasFilter && urns != null) { @@ -2249,7 +2007,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.ColumnMasterKeys.Refresh(); + parentDatabase.ColumnMasterKeys.Refresh(true); } var retValue = parentDatabase.ColumnMasterKeys; if (retValue != null) @@ -2257,12 +2015,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/ColumnMasterKey" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "ColumnMasterKey"); } if (hasFilter && urns != null) { @@ -2293,7 +2046,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.ColumnEncryptionKeys.Refresh(); + parentDatabase.ColumnEncryptionKeys.Refresh(true); } var retValue = parentDatabase.ColumnEncryptionKeys; if (retValue != null) @@ -2301,12 +2054,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/ColumnEncryptionKey" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "ColumnEncryptionKey"); } if (hasFilter && urns != null) { @@ -2364,7 +2112,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServiceBroker.Services.Refresh(); + parentServiceBroker.Services.Refresh(true); } var retValue = parentServiceBroker.Services; if (retValue != null) @@ -2372,12 +2120,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServiceBroker.Urn.ToString()}/BrokerService" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServiceBroker, filter, "BrokerService"); } if (hasFilter && urns != null) { @@ -2408,7 +2151,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServiceBroker.ServiceContracts.Refresh(); + parentServiceBroker.ServiceContracts.Refresh(true); } var retValue = parentServiceBroker.ServiceContracts; if (retValue != null) @@ -2416,12 +2159,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServiceBroker.Urn.ToString()}/ServiceContract" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServiceBroker, filter, "ServiceContract"); } if (hasFilter && urns != null) { @@ -2452,7 +2190,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServiceBroker.Queues.Refresh(); + parentServiceBroker.Queues.Refresh(true); } var retValue = parentServiceBroker.Queues; if (retValue != null) @@ -2460,12 +2198,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServiceBroker.Urn.ToString()}/ServiceQueue" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServiceBroker, filter, "ServiceQueue"); } if (hasFilter && urns != null) { @@ -2496,7 +2229,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServiceBroker.RemoteServiceBindings.Refresh(); + parentServiceBroker.RemoteServiceBindings.Refresh(true); } var retValue = parentServiceBroker.RemoteServiceBindings; if (retValue != null) @@ -2504,12 +2237,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServiceBroker.Urn.ToString()}/RemoteServiceBinding" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServiceBroker, filter, "RemoteServiceBinding"); } if (hasFilter && urns != null) { @@ -2540,7 +2268,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServiceBroker.Priorities.Refresh(); + parentServiceBroker.Priorities.Refresh(true); } var retValue = parentServiceBroker.Priorities; if (retValue != null) @@ -2548,12 +2276,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServiceBroker.Urn.ToString()}/BrokerPriority" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServiceBroker, filter, "BrokerPriority"); } if (hasFilter && urns != null) { @@ -2584,7 +2307,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentServiceBroker.MessageTypes.Refresh(); + parentServiceBroker.MessageTypes.Refresh(true); } var retValue = parentServiceBroker.MessageTypes; if (retValue != null) @@ -2592,12 +2315,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentServiceBroker.Urn.ToString()}/MessageType" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentServiceBroker, filter, "MessageType"); } if (hasFilter && urns != null) { @@ -2628,7 +2346,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.ExternalDataSources.Refresh(); + parentDatabase.ExternalDataSources.Refresh(true); } var retValue = parentDatabase.ExternalDataSources; if (retValue != null) @@ -2636,12 +2354,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/ExternalDataSource" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "ExternalDataSource"); } if (hasFilter && urns != null) { @@ -2672,7 +2385,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.ExternalFileFormats.Refresh(); + parentDatabase.ExternalFileFormats.Refresh(true); } var retValue = parentDatabase.ExternalFileFormats; if (retValue != null) @@ -2680,12 +2393,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/ExternalFileFormat" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "ExternalFileFormat"); } if (hasFilter && urns != null) { @@ -2716,7 +2424,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.StoredProcedures.Refresh(); + parentDatabase.StoredProcedures.Refresh(true); } var retValue = parentDatabase.StoredProcedures; if (retValue != null) @@ -2724,12 +2432,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/StoredProcedure" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "StoredProcedure"); } if (hasFilter && urns != null) { @@ -2760,7 +2463,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.ExtendedStoredProcedures.Refresh(); + parentDatabase.ExtendedStoredProcedures.Refresh(true); } var retValue = parentDatabase.ExtendedStoredProcedures; if (retValue != null) @@ -2768,12 +2471,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Urn.ToString()}/ExtendedStoredProcedure" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase, filter, "ExtendedStoredProcedure"); } if (hasFilter && urns != null) { @@ -2804,7 +2502,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentStoredProcedure.Parameters.Refresh(); + parentStoredProcedure.Parameters.Refresh(true); } var retValue = parentStoredProcedure.Parameters; if (retValue != null) @@ -2812,12 +2510,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentStoredProcedure.Urn.ToString()}/Parameter" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentStoredProcedure, filter, "Parameter"); } if (hasFilter && urns != null) { @@ -2835,7 +2528,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentUserDefinedAggregate.Parameters.Refresh(); + parentUserDefinedAggregate.Parameters.Refresh(true); } var retValue = parentUserDefinedAggregate.Parameters; if (retValue != null) @@ -2843,12 +2536,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentUserDefinedAggregate.Urn.ToString()}/Parameter" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentUserDefinedAggregate, filter, "Parameter"); } if (hasFilter && urns != null) { @@ -2866,7 +2554,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentUserDefinedFunction.Parameters.Refresh(); + parentUserDefinedFunction.Parameters.Refresh(true); } var retValue = parentUserDefinedFunction.Parameters; if (retValue != null) @@ -2874,12 +2562,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentUserDefinedFunction.Urn.ToString()}/Parameter" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentUserDefinedFunction, filter, "Parameter"); } if (hasFilter && urns != null) { @@ -2910,7 +2593,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentPartitionFunction.PartitionFunctionParameters.Refresh(); + parentPartitionFunction.PartitionFunctionParameters.Refresh(true); } var retValue = parentPartitionFunction.PartitionFunctionParameters; if (retValue != null) @@ -2918,12 +2601,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentPartitionFunction.Urn.ToString()}/PartitionFunctionParameter" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentPartitionFunction, filter, "PartitionFunctionParameter"); } if (hasFilter && urns != null) { @@ -2954,7 +2632,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel bool hasFilter = !string.IsNullOrEmpty(filter); if (refresh) { - parentDatabase.Parent.SystemDataTypes.Refresh(); + parentDatabase.Parent.SystemDataTypes.Refresh(true); } var retValue = parentDatabase.Parent.SystemDataTypes; if (retValue != null) @@ -2962,12 +2640,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel HashSet urns = null; if (hasFilter) { - string urn = $"{parentDatabase.Parent.Urn.ToString()}/SystemDataType" + filter; - Enumerator en = new Enumerator(); - Request request = new Request(new Urn(urn)); - ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject); - EnumResult result = en.Process(serverConnection, request); - urns = GetUrns(result); + urns = GetUrns(context, parentDatabase.Parent, filter, "SystemDataType"); } if (hasFilter && urns != null) { diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt index 58090a07..ccda2a28 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModel.tt @@ -15,8 +15,6 @@ using System; using System.Collections.Generic; using System.Composition; using System.Linq; -using Microsoft.SqlServer.Management.Common; -using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Smo.Broker; @@ -70,7 +68,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel WriteLine("if (refresh)"); WriteLine("{"); PushIndent(indent); - WriteLine(string.Format("{0}.{1}.Refresh();", parentVar, navigationPath)); + WriteLine(string.Format("{0}.{1}.Refresh({2});", parentVar, navigationPath, IsCollection(nodeElement) ? "true" : "")); PopIndent(); WriteLine("}"); @@ -96,12 +94,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel WriteLine("if (hasFilter)"); WriteLine("{"); PushIndent(indent); - WriteLine(string.Format("string urn = $\"{{{0}.Urn.ToString()}}/{1}\" + filter;", fieldForUrn, nodeType)); - WriteLine("Enumerator en = new Enumerator();"); - WriteLine("Request request = new Request(new Urn(urn));"); - WriteLine("ServerConnection serverConnection = new ServerConnection(context.Server.ConnectionContext.SqlConnectionObject);"); - WriteLine("EnumResult result = en.Process(serverConnection, request);"); - WriteLine("urns = GetUrns(result);"); + WriteLine(string.Format("urns = GetUrns(context, {0}, filter, \"{1}\");", fieldForUrn, nodeType)); PopIndent(); WriteLine("}"); WriteLine("if (hasFilter && urns != null)"); diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml index 9a94341d..034067d7 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoQueryModelDefinition.xml @@ -112,6 +112,7 @@ + - @@ -122,7 +123,7 @@ - + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml index 4202089b..01c670b4 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeDefinition.xml @@ -6,7 +6,10 @@ - + + + + @@ -30,7 +33,11 @@ --> - + + + + + + @@ -218,15 +224,21 @@ + + + + + + - + @@ -283,12 +295,12 @@ - + - + @@ -302,12 +314,20 @@ - + UserDefinedFunctionType.Table + + + + UserDefinedFunctionType.Table + + + + @@ -322,6 +342,14 @@ + + + + UserDefinedFunctionType.Scalar + + + + @@ -340,6 +368,7 @@ + @@ -387,22 +416,22 @@ - + - + - + - + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs index 109a26f8..96692049 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.cs @@ -152,12 +152,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Databases, NodeType = "Folder", NodeTypeId = NodeTypes.Databases, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Security, 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, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -165,6 +167,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ServerObjects, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerObjects, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotContainedUser, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -177,12 +180,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { public override IEnumerable ApplicableParents() { return new[] { "Databases" }; } + public override IEnumerable Filters + { + get + { + var filters = new List(); + filters.Add(new NodeFilter + { + Property = "IsSystemObject", + Type = typeof(bool), + Values = new List { 0 }, + }); + return filters; + } + } + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemDatabases, 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, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -216,6 +235,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_LinkedServerLogins, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelLinkedServerLogins, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -223,12 +243,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Logins, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelLogins, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_ServerRoles, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerRoles, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -236,6 +258,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Credentials, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelCredentials, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -243,6 +266,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_CryptographicProviders, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelCryptographicProviders, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.NotDebugInstance, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -250,6 +274,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ServerAudits, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerAudits, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -257,6 +282,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ServerAuditSpecifications, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerAuditSpecifications, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -283,6 +309,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Endpoints, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelEndpoints, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -290,18 +317,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_LinkedServers, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelLinkedServers, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_ServerTriggers, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelServerTriggers, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_ErrorMessages, NodeType = "Folder", NodeTypeId = NodeTypes.ServerLevelErrorMessages, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -320,6 +350,36 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel internal partial class SystemDatabasesChildFactory : SmoChildFactoryBase { public override IEnumerable ApplicableParents() { return new[] { "SystemDatabases" }; } + + public override IEnumerable Filters + { + get + { + var filters = new List(); + filters.Add(new NodeFilter + { + Property = "IsSystemObject", + Type = typeof(bool), + Values = new List { 1 }, + }); + return filters; + } + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlDatabaseQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new DatabaseTreeNode(); + InitializeChild(parent, child, context); + return child; + } } [Export(typeof(ChildFactory))] @@ -598,30 +658,35 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Tables, NodeType = "Folder", NodeTypeId = NodeTypes.Tables, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Views, NodeType = "Folder", NodeTypeId = NodeTypes.Views, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Synonyms, NodeType = "Folder", NodeTypeId = NodeTypes.Synonyms, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Programmability, NodeType = "Folder", NodeTypeId = NodeTypes.Programmability, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_ExternalResources, NodeType = "Folder", NodeTypeId = NodeTypes.ExternalResources, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -629,6 +694,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ServiceBroker, NodeType = "Folder", NodeTypeId = NodeTypes.ServiceBroker, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -636,6 +702,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Storage, NodeType = "Folder", NodeTypeId = NodeTypes.Storage, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -643,6 +710,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Security, NodeType = "Folder", NodeTypeId = NodeTypes.Security, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -676,25 +744,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { var filters = new List(); filters.Add(new NodeFilter - { - Property = "IsFileTable", - Type = typeof(bool), - Values = new List { 0 }, - }); - filters.Add(new NodeFilter { Property = "IsSystemObject", Type = typeof(bool), Values = new List { 0 }, }); filters.Add(new NodeFilter - { - Property = "IsExternal", - Type = typeof(bool), - ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, - Values = new List { 0 }, - }); - filters.Add(new NodeFilter { Property = "TemporalType", Type = typeof(Enum), @@ -715,6 +770,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemTables, NodeType = "Folder", NodeTypeId = NodeTypes.SystemTables, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -763,6 +819,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemViews, NodeType = "Folder", NodeTypeId = NodeTypes.SystemViews, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -820,24 +877,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_StoredProcedures, NodeType = "Folder", NodeTypeId = NodeTypes.StoredProcedures, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Functions, NodeType = "Folder", NodeTypeId = NodeTypes.Functions, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_DatabaseTriggers, NodeType = "Folder", NodeTypeId = NodeTypes.DatabaseTriggers, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Assemblies, NodeType = "Folder", NodeTypeId = NodeTypes.Assemblies, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -845,12 +906,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Types, NodeType = "Folder", NodeTypeId = NodeTypes.Types, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Sequences, NodeType = "Folder", NodeTypeId = NodeTypes.Sequences, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -877,6 +940,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ExternalDataSources, NodeType = "Folder", NodeTypeId = NodeTypes.ExternalDataSources, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -884,6 +948,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ExternalFileFormats, NodeType = "Folder", NodeTypeId = NodeTypes.ExternalFileFormats, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -910,36 +975,42 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_MessageTypes, NodeType = "Folder", NodeTypeId = NodeTypes.MessageTypes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Contracts, NodeType = "Folder", NodeTypeId = NodeTypes.Contracts, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Queues, NodeType = "Folder", NodeTypeId = NodeTypes.Queues, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Services, NodeType = "Folder", NodeTypeId = NodeTypes.Services, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_RemoteServiceBindings, NodeType = "Folder", NodeTypeId = NodeTypes.RemoteServiceBindings, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_BrokerPriorities, NodeType = "Folder", NodeTypeId = NodeTypes.BrokerPriorities, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -966,18 +1037,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_FileGroups, NodeType = "Folder", NodeTypeId = NodeTypes.FileGroups, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_FullTextCatalogs, NodeType = "Folder", NodeTypeId = NodeTypes.FullTextCatalogs, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_FullTextStopLists, NodeType = "Folder", NodeTypeId = NodeTypes.FullTextStopLists, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -985,24 +1059,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_LogFiles, NodeType = "Folder", NodeTypeId = NodeTypes.SqlLogFiles, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_PartitionFunctions, NodeType = "Folder", NodeTypeId = NodeTypes.PartitionFunctions, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_PartitionSchemes, NodeType = "Folder", NodeTypeId = NodeTypes.PartitionSchemes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SearchPropertyLists, NodeType = "Folder", NodeTypeId = NodeTypes.SearchPropertyLists, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1029,24 +1107,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Users, NodeType = "Folder", NodeTypeId = NodeTypes.Users, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Roles, NodeType = "Folder", NodeTypeId = NodeTypes.Roles, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Schemas, NodeType = "Folder", NodeTypeId = NodeTypes.Schemas, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_AsymmetricKeys, NodeType = "Folder", NodeTypeId = NodeTypes.AsymmetricKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1054,6 +1136,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Certificates, NodeType = "Folder", NodeTypeId = NodeTypes.Certificates, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1061,6 +1144,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SymmetricKeys, NodeType = "Folder", NodeTypeId = NodeTypes.SymmetricKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1068,6 +1152,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_DatabaseScopedCredentials, NodeType = "Folder", NodeTypeId = NodeTypes.DatabaseScopedCredentials, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1075,6 +1160,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_DatabaseEncryptionKeys, NodeType = "Folder", NodeTypeId = NodeTypes.DatabaseEncryptionKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1082,6 +1168,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_MasterKeys, NodeType = "Folder", NodeTypeId = NodeTypes.MasterKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1089,6 +1176,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_DatabaseAuditSpecifications, NodeType = "Folder", NodeTypeId = NodeTypes.DatabaseAuditSpecifications, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1096,6 +1184,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SecurityPolicies, NodeType = "Folder", NodeTypeId = NodeTypes.SecurityPolicies, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1103,6 +1192,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_AlwaysEncryptedKeys, NodeType = "Folder", NodeTypeId = NodeTypes.AlwaysEncryptedKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1186,36 +1276,42 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Columns, NodeType = "Folder", NodeTypeId = NodeTypes.Columns, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Keys, NodeType = "Folder", NodeTypeId = NodeTypes.Keys, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Constraints, NodeType = "Folder", NodeTypeId = NodeTypes.Constraints, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Triggers, NodeType = "Folder", NodeTypeId = NodeTypes.Triggers, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Indexes, NodeType = "Folder", NodeTypeId = NodeTypes.Indexes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Statistics, NodeType = "Folder", NodeTypeId = NodeTypes.Statistics, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -1248,24 +1344,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Columns, NodeType = "Folder", NodeTypeId = NodeTypes.Columns, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Constraints, NodeType = "Folder", NodeTypeId = NodeTypes.Constraints, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Indexes, NodeType = "Folder", NodeTypeId = NodeTypes.Indexes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Statistics, NodeType = "Folder", NodeTypeId = NodeTypes.Statistics, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -1299,12 +1399,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Columns, NodeType = "Folder", NodeTypeId = NodeTypes.Columns, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Statistics, NodeType = "Folder", NodeTypeId = NodeTypes.Statistics, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -1562,24 +1664,28 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Columns, NodeType = "Folder", NodeTypeId = NodeTypes.Columns, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Triggers, NodeType = "Folder", NodeTypeId = NodeTypes.Triggers, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Indexes, NodeType = "Folder", NodeTypeId = NodeTypes.Indexes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Statistics, NodeType = "Folder", NodeTypeId = NodeTypes.Statistics, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -1609,22 +1715,33 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_SystemFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemFunctions, + IsSystemObject = true, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_TableValuedFunctions, NodeType = "Folder", NodeTypeId = NodeTypes.TableValuedFunctions, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_ScalarValuedFunctions, NodeType = "Folder", NodeTypeId = NodeTypes.ScalarValuedFunctions, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_AggregateFunctions, NodeType = "Folder", NodeTypeId = NodeTypes.AggregateFunctions, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1639,6 +1756,45 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel } } + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemFunctions" }; } + + protected override void OnExpandPopulateFolders(IList currentChildren, TreeNode parent) + { + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_TableValuedFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemTableValuedFunctions, + IsSystemObject = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_ScalarValuedFunctions, + NodeType = "Folder", + NodeTypeId = NodeTypes.SystemScalarValuedFunctions, + IsSystemObject = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new Type[0]; } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new TableValuedFunctionTreeNode(); + InitializeChild(parent, child, context); + return child; + } + } + [Export(typeof(ChildFactory))] [Shared] internal partial class DatabaseTriggersChildFactory : SmoChildFactoryBase @@ -1699,18 +1855,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemDataTypes, NodeType = "Folder", NodeTypeId = NodeTypes.SystemDataTypes, + IsSystemObject = true, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_UserDefinedDataTypes, NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedDataTypes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_UserDefinedTableTypes, NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedTableTypes, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1718,6 +1877,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_UserDefinedTypes, NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedTypes, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1725,6 +1885,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_XMLSchemaCollections, NodeType = "Folder", NodeTypeId = NodeTypes.XmlSchemaCollections, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1775,48 +1936,56 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemExactNumerics, NodeType = "Folder", NodeTypeId = NodeTypes.SystemExactNumerics, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemApproximateNumerics, NodeType = "Folder", NodeTypeId = NodeTypes.SystemApproximateNumerics, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemDateAndTime, NodeType = "Folder", NodeTypeId = NodeTypes.SystemDateAndTimes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemCharacterStrings, NodeType = "Folder", NodeTypeId = NodeTypes.SystemCharacterStrings, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemUnicodeCharacterStrings, NodeType = "Folder", NodeTypeId = NodeTypes.SystemUnicodeCharacterStrings, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemBinaryStrings, NodeType = "Folder", NodeTypeId = NodeTypes.SystemBinaryStrings, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemOtherDataTypes, NodeType = "Folder", NodeTypeId = NodeTypes.SystemOtherDataTypes, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_SystemCLRDataTypes, NodeType = "Folder", NodeTypeId = NodeTypes.SystemClrDataTypes, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1824,6 +1993,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemSpatialDataTypes, NodeType = "Folder", NodeTypeId = NodeTypes.SystemSpatialDataTypes, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.Azure|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -1944,18 +2114,21 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Columns, NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedTableTypeColumns, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Keys, NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedTableTypeKeys, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_Constraints, NodeType = "Folder", NodeTypeId = NodeTypes.UserDefinedTableTypeConstraints, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -2362,6 +2535,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemStoredProcedures, NodeType = "Folder", NodeTypeId = NodeTypes.SystemStoredProcedures, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -2432,6 +2606,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Parameters, NodeType = "Folder", NodeTypeId = NodeTypes.StoredProcedureParameters, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -2493,7 +2668,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel { Property = "FunctionType", Type = typeof(Enum), - ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, Values = new List { { UserDefinedFunctionType.Table } @@ -2525,6 +2699,52 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel } } + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemTableValuedFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemTableValuedFunctions" }; } + + public override IEnumerable Filters + { + get + { + var filters = new List(); + filters.Add(new NodeFilter + { + Property = "FunctionType", + Type = typeof(Enum), + Values = new List + { + { UserDefinedFunctionType.Table } + } + }); + filters.Add(new NodeFilter + { + Property = "IsSystemObject", + Type = typeof(bool), + Values = new List { 1 }, + }); + return filters; + } + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedFunctionQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new TableValuedFunctionTreeNode(); + InitializeChild(parent, child, context); + return child; + } + } + [Export(typeof(ChildFactory))] [Shared] internal partial class TableValuedFunctionChildFactory : SmoChildFactoryBase @@ -2537,6 +2757,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Parameters, NodeType = "Folder", NodeTypeId = NodeTypes.TableValuedFunctionParameters, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -2630,6 +2851,52 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel } } + [Export(typeof(ChildFactory))] + [Shared] + internal partial class SystemScalarValuedFunctionsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "SystemScalarValuedFunctions" }; } + + public override IEnumerable Filters + { + get + { + var filters = new List(); + filters.Add(new NodeFilter + { + Property = "FunctionType", + Type = typeof(Enum), + Values = new List + { + { UserDefinedFunctionType.Scalar } + } + }); + filters.Add(new NodeFilter + { + Property = "IsSystemObject", + Type = typeof(bool), + Values = new List { 1 }, + }); + return filters; + } + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlUserDefinedFunctionQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new ScalarValuedFunctionTreeNode(); + InitializeChild(parent, child, context); + return child; + } + } + [Export(typeof(ChildFactory))] [Shared] internal partial class ScalarValuedFunctionChildFactory : SmoChildFactoryBase @@ -2642,6 +2909,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Parameters, NodeType = "Folder", NodeTypeId = NodeTypes.ScalarValuedFunctionParameters, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -2722,6 +2990,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_Parameters, NodeType = "Folder", NodeTypeId = NodeTypes.AggregateFunctionParameters, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -2994,6 +3263,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_FilegroupFiles, NodeType = "Folder", NodeTypeId = NodeTypes.FileGroupFiles, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); } @@ -3067,12 +3337,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_DatabaseRoles, NodeType = "Folder", NodeTypeId = NodeTypes.DatabaseRoles, + IsSystemObject = false, SortPriority = SmoTreeNode.NextSortPriority, }); currentChildren.Add(new FolderNode { NodeValue = SR.SchemaHierarchy_ApplicationRoles, NodeType = "Folder", NodeTypeId = NodeTypes.ApplicationRoles, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2005|ValidForFlag.Sql2008|ValidForFlag.Sql2012|ValidForFlag.Sql2014|ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -3315,6 +3587,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ColumnMasterKeys, NodeType = "Folder", NodeTypeId = NodeTypes.ColumnMasterKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -3322,6 +3595,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_ColumnEncryptionKeys, NodeType = "Folder", NodeTypeId = NodeTypes.ColumnEncryptionKeys, + IsSystemObject = false, ValidFor = ValidForFlag.Sql2016|ValidForFlag.AzureV12, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -3444,6 +3718,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemMessageTypes, NodeType = "Folder", NodeTypeId = NodeTypes.SystemMessageTypes, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -3503,6 +3778,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemContracts, NodeType = "Folder", NodeTypeId = NodeTypes.SystemContracts, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -3562,6 +3838,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemQueues, NodeType = "Folder", NodeTypeId = NodeTypes.SystemQueues, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); @@ -3621,6 +3898,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel NodeValue = SR.SchemaHierarchy_SystemServices, NodeType = "Folder", NodeTypeId = NodeTypes.SystemServices, + IsSystemObject = true, IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt index 9ad0469a..759b1c4b 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/TreeNodeGenerator.tt @@ -208,6 +208,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel WriteLine(string.Format(" NodeValue = {0},", childAsXmlElement.GetAttribute("LocLabel"))); WriteLine(string.Format(" NodeType = \"{0}\",", "Folder")); WriteLine(string.Format(" NodeTypeId = NodeTypes.{0},", child.GetAttribute("Name"))); + WriteLine(string.Format(" IsSystemObject = {0},", child.GetAttribute("IsSystemObject") == "1" ? "true" : "false")); if (msShippedOwned != null) { diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs index 2aadb17a..9d47af92 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -298,6 +298,13 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer //Verify the test databases is in the list Assert.NotNull(databases); + Assert.False(databases.Any(x => x.Label == "master")); + var systemDatabasesNode = databasesChildren.FirstOrDefault(x => x.Label == SR.SchemaHierarchy_SystemDatabases); + Assert.NotNull(systemDatabasesNode); + + var systemDatabases = await _service.ExpandNode(session, systemDatabasesNode.NodePath); + Assert.True(systemDatabases.Any(x => x.Label == "master")); + databaseNode = databases.FirstOrDefault(d => d.Label == databaseName); } else @@ -305,6 +312,9 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer Assert.Equal(nodeInfo.NodeType, NodeTypes.Database.ToString()); databaseNode = session.Root.ToNodeInfo(); Assert.True(databaseNode.Label.Contains(databaseName)); + var databasesChildren = await _service.ExpandNode(session, databaseNode.NodePath); + Assert.False(databasesChildren.Any(x => x.Label == SR.SchemaHierarchy_SystemDatabases)); + } Assert.NotNull(databaseNode); return databaseNode; diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs index c6f61b4c..d971cd01 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodeTests.cs @@ -327,7 +327,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer smoObjectMock.SetupGet(s => s.Name).Returns(dbName); Mock querierMock = new Mock(); - querierMock.Setup(q => q.Query(It.IsAny(), "", false)) + querierMock.Setup(q => q.Query(It.IsAny(), It.IsAny(), false)) .Returns(smoObjectMock.Object.SingleItemAsEnumerable()); ServiceProvider.Register(() => new[] { querierMock.Object });