コード例 #1
0
        public static DependencyItem[] GetDependsOnSelected(this IDatabaseStructure db, DependencyItem selected, bool processReferences)
        {
            var res = new List <DependencyItem>();

            if (selected != null)
            {
                foreach (var spec in db.GetAllSpecificObjects())
                {
                    if (spec.DependsOn != null && spec.DependsOn.Contains(selected))
                    {
                        res.Add(new DependencyItem
                        {
                            Name       = spec.ObjectName,
                            ObjectType = spec.ObjectType,
                        });
                    }
                }
                if (processReferences && selected.ObjectType == "table")
                {
                    var tbl = db.FindTable(selected.Name);
                    if (tbl != null)
                    {
                        foreach (var fk in tbl.GetReferencedFrom())
                        {
                            res.Add(new DependencyItem
                            {
                                Name       = fk.Table.FullName,
                                ObjectType = "table",
                            });
                        }
                    }
                }
            }
            return(res.ToArray());
        }
コード例 #2
0
        public static DependencyItem[] GetSelectedDependsOn(this IDatabaseStructure db, DependencyItem selected, bool processReferences)
        {
            var res = new List <DependencyItem>();

            if (selected != null)
            {
                var obj = db.FindSpecificObject(selected.ObjectType, selected.Name);
                if (obj != null && obj.DependsOn != null)
                {
                    res.AddRange(obj.DependsOn);
                }
                if (processReferences && selected.ObjectType == "table")
                {
                    var tbl = db.FindTable(selected.Name);
                    if (tbl != null)
                    {
                        foreach (var fk in tbl.GetConstraints <IForeignKey>())
                        {
                            res.Add(new DependencyItem
                            {
                                Name       = fk.PrimaryKeyTable,
                                ObjectType = "table",
                            });
                        }
                    }
                }
            }
            return(res.ToArray());
        }
コード例 #3
0
        public static ITableStructure FindSimilarTable(this IDatabaseStructure db, NameWithSchema name)
        {
            var res = db.FindTable(name);

            if (res != null)
            {
                return(res);
            }
            return((ITableStructure)(from t in db.Tables where t.FullName.Name.ToLower() == name.Name.ToLower() select t).FirstOrDefault());
        }
コード例 #4
0
 public static IColumnStructure FindColumn(this IDatabaseStructure db, IColumnStructure column)
 {
     return((IColumnStructure)db.FindTable(column.Table.FullName).Columns.First(c => c.ColumnName == column.ColumnName));
 }
コード例 #5
0
 public static IConstraint FindConstraint(this IDatabaseStructure db, IConstraint constraint)
 {
     return(db.FindTable(constraint.Table.FullName).Constraints.First(c => c.Name == constraint.Name && c.Type == constraint.Type));
 }