private void CreateFolderNodesForDatabase(ObjectExplorerNode model)
 {
     if (!(model.Data is Database))
     {
         return;
     }
     DataSource.Add(ObjectExplorerNodeFactory.CreateFolderNode(GetNewNodeId(), GlobalStrings.FolderTypes.TableFolder,
                                                               model));
     DataSource.Add(ObjectExplorerNodeFactory.CreateFolderNode(GetNewNodeId(), GlobalStrings.FolderTypes.ViewFolder,
                                                               model));
     DataSource.Add(ObjectExplorerNodeFactory.CreateFolderNode(GetNewNodeId(),
                                                               GlobalStrings.FolderTypes.StoreProcedureFolder, model));
     DataSource.Add(ObjectExplorerNodeFactory.CreateFolderNode(GetNewNodeId(),
                                                               GlobalStrings.FolderTypes.FunctionsFolder, model));
 }
        private void CreateUserDatabaseNodes(ObjectExplorerNode model)
        {
            if (!(model.Data is Server server))
            {
                return;
            }
            if (server.Databases.Count <= 0)
            {
                CreateEmptyNode(model);
                return;
            }

            DataSource.Add(ObjectExplorerNodeFactory.CreateFolderNode(GetNewNodeId(), GlobalStrings.FolderTypes.SystemDatabaseFolder, model));

            foreach (Database db in server.Databases) //TODO - This is probably not the most elegant way to handle this...
            {
                if (!systemDatabaseNames.Contains(db.Name))
                {
                    DataSource.Add(ObjectExplorerNodeFactory.CreateDatabaseNode(GetNewNodeId(), model.Id, db));
                }
            }
        }
        private void CreateStoredProcedureNodes(ObjectExplorerNode model)
        {
            if (!(model.Data is Database database))
            {
                return;
            }
            if ((database.StoredProcedures.Count <= 0))
            {
                CreateEmptyNode(model);
                return;
            }

            DataSource.Add(ObjectExplorerNodeFactory.CreateFolderNode(GetNewNodeId(), GlobalStrings.FolderTypes.SystemStoredProcedureFolder, model));

            var nonSystemStoredProcedures = database.StoredProcedures.Cast <StoredProcedure>()
                                            .Where(r => r.IsSystemObject == false).ToList();

            foreach (var storedProcedure in nonSystemStoredProcedures)
            {
                DataSource.Add(ObjectExplorerNodeFactory.CreateStoredProcedureNode(GetNewNodeId(), model.Id, storedProcedure));
            }
        }