Пример #1
0
        private void DisplyChildObjects(string rootNodeHader, TreeViewItem currentObjectTreeViewItem,
                                        TSqlObject currentObject, Dictionary <string, TreeViewItem> childObjectTypes)
        {
            var children = currentObject.GetChildren();

            foreach (var child in children.OrderBy(p => p, new SqlObjectComparer()))
            {
                var type = child.ObjectType.Name;
                var typeContainerHeader = GetContainerHeader(type);

                if (!childObjectTypes.ContainsKey(typeContainerHeader))
                {
                    var item = AddTreeItem(typeContainerHeader, currentObjectTreeViewItem, _defaultForeground);
                    childObjectTypes.Add(typeContainerHeader, item);
                }

                var childTreeViewItem = AddTreeItem(child.Name.ToString(), childObjectTypes[typeContainerHeader],
                                                    _defaultForeground);

                DisplayObject(rootNodeHader, child, childTreeViewItem);
            }
            var repository = ModelRepository.GetRepository();

            if (repository.LoadScriptDom())
            {
                TSqlFragment fragment;

                TSqlModelUtils.TryGetFragmentForAnalysis(currentObject, out fragment);
                var frgPrc = new TSqlFragmentProcess.TSqlFragmentProcess(this);
                frgPrc.ProcessTSQLFragment(fragment, currentObjectTreeViewItem);
            }
        }
Пример #2
0
        void AddChildren(TSqlObject obj_root, List <TSqlObject> obj_list)
        {
            List <TSqlObject> tmp_lis = obj_root.GetChildren().ToList();

            if (tmp_lis.Count() > 0)
            {
                obj_list.AddRange(tmp_lis);
                foreach (var t in tmp_lis)
                {
                    AddChildren(t, obj_list);
                }
            }
        }
Пример #3
0
      static  void DumpChildren(TSqlObject parent, int depth)
      {
          DumpScript(parent);
          foreach (var property in parent.ObjectType.Properties)
          {
              DumpProperty(property, parent);
          }

          foreach (var child in parent.GetChildren())
            {
                DumpChildren(child, depth + 1);
            }
      }
Пример #4
0
        static void DumpChildren(TSqlObject parent, int depth)
        {
            DumpScript(parent);
            foreach (var property in parent.ObjectType.Properties)
            {
                DumpProperty(property, parent);
            }

            foreach (var child in parent.GetChildren())
            {
                DumpChildren(child, depth + 1);
            }
        }
Пример #5
0
        private List <string> GetKeyColumns(TSqlObject table)
        {
            var keys = new List <string>();

            var primaryKey = table.GetChildren().FirstOrDefault(p => p.ObjectType == ModelSchema.PrimaryKeyConstraint);

            if (null == primaryKey)
            {
                return(keys);
            }

            foreach (var column in primaryKey.GetReferencedRelationshipInstances(PrimaryKeyConstraint.Columns))
            {
                keys.Add(column.ObjectName.GetName());
            }

            return(keys);
        }
Пример #6
0
        public NodeReference Visit(TSqlObject table)
        {
            Console.WriteLine("Discovered table {0}", table.Name);

            var tableNode = _graphClient.Create(new Nodes.Table
            {
                Id   = table.Name.ToString(),
                Name = table.Name.ToString()
            });

            var columnVisitor = new ColumnVisitor(_graphClient);

            foreach (var columnNode in table.GetChildren().Where(x => x.ObjectType == ModelSchema.Column).Select(columnVisitor.Visit))
            {
                _graphClient.CreateRelationship(tableNode, new TableContainsColumn(columnNode));
            }

            return(tableNode);
        }
Пример #7
0
        private void DisplyChildObjects(string rootNodeHader, TreeViewItem currentObjectTreeViewItem,
            TSqlObject currentObject, Dictionary<string, TreeViewItem> childObjectTypes)
        {
            var children = currentObject.GetChildren();

            foreach (var child in children.OrderBy(p => p, new SqlObjectComparer()))
            {
                
                var type = child.ObjectType.Name;
                var typeContainerHeader = GetContainerHeader(type);

                if (!childObjectTypes.ContainsKey(typeContainerHeader))
                {
                    var item = AddTreeItem(typeContainerHeader, currentObjectTreeViewItem, _defaultForeground);
                    childObjectTypes.Add(typeContainerHeader, item);
                }

                var childTreeViewItem = AddTreeItem(child.Name.ToString(), childObjectTypes[typeContainerHeader],
                    _defaultForeground);

                DisplayObject(rootNodeHader, child, childTreeViewItem);
            }
            var repository = ModelRepository.GetRepository();

            if (repository.LoadScriptDom())
            {
                TSqlFragment fragment;

                TSqlModelUtils.TryGetFragmentForAnalysis(currentObject, out fragment);
                var frgPrc = new TSqlFragmentProcess.TSqlFragmentProcess(this);
                frgPrc.ProcessTSQLFragment(fragment, currentObjectTreeViewItem);
            }
        }
Пример #8
0
        private List<string> GetKeyColumns(TSqlObject table)
        {
            var keys = new List<string>();

            var primaryKey = table.GetChildren().FirstOrDefault(p => p.ObjectType == ModelSchema.PrimaryKeyConstraint);

            if (null == primaryKey)
                return keys;

            foreach (var column in primaryKey.GetReferencedRelationshipInstances(PrimaryKeyConstraint.Columns))
            {
                keys.Add(column.ObjectName.GetName());
            }

            return keys;
        }