Exemplo n.º 1
0
        public static void CreateFilteredDependenciesGraph(Database database, Table startTable, Plan plan)
        {
            Set<Table> visited = new Set<Table>();
            Stack<Table> seen = new Stack<Table>();

            seen.Push(startTable);

            // The relations that, as a precondition of the delete, must not exist:
            while (seen.Count > 0)
            {
                Table table = seen.Pop();

                visited.UnionUpdate(table);

                foreach (ForeignKeyConstraint constraint in table.ForeignKeyDependencies)
                {
                    if (plan.IsConstraintExcludedFromDependencyDiagram(constraint)) continue;

                    if (!visited.Contains(constraint.Table))
                    {
                        seen.Push(constraint.Table);
                    }
                }
            }

            CreateDependenciesGraph(database, visited);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            DatabaseConnectionString connectionString = new DatabaseConnectionString();
            connectionString.ServerName = ".\\SQLEXPRESS";
            connectionString.DatabaseName = "Avance";
            connectionString.UseIntegratedAuthentication = false;
            connectionString.Username = "******";
            connectionString.Password = "******";

            Database database;

            using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
            {
                connection.Open();

                database = Database.FromConnection(connection);
            }

            Plan plan = new Plan(database);

            plan.AddPrecondition("InvoiceLineSource", "CourierJobId");
            plan.AddPrecondition("JobDriverEffort", "JobId");
            plan.AddPrecondition("Transfer", "JobNoteId");
            plan.AddPrecondition("Transfer", "WaypointId");

            Dependencies.CreateDependenciesGraph(database);
        }