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());
        }
 public static ISpecificObjectStructure FindSpecificObject(this IDatabaseStructure db, ISpecificObjectStructure obj)
 {
     return(db.FindSpecificObject(obj.ObjectType, obj.ObjectName));
 }