public void JoinUserAndProducts() { DataTableJoinVertex users = this.joinGraph.AddVertex(this.dataSource.Users, "U"); DataTableJoinVertex products = this.joinGraph.AddVertex(this.dataSource.Products, "P"); this.joinGraph.AddEdge(users, products, JoinType.Inner); }
public void JoinUserAndOrders() { DataTableJoinVertex users = this.joinGraph.AddVertex(this.dataSource.Users, "U"); DataTableJoinVertex orders = this.joinGraph.AddVertex(this.dataSource.Orders, "O"); this.joinGraph.AddEdge(users, orders, JoinType.Inner); }
public void UsersOnly() { DataTableJoinVertex users = this.graph.AddVertex(this.dataSource.Users, "U"); algo = new DataTableJoinSortAlgorithm(this.graph); algo.Compute(); Assert.IsNotNull(algo.StartVertex); Assert.AreEqual(users, algo.StartVertex); CollectionAssert.AreCountEqual(0, algo.Joins); ShowJoins(); }
public void JoinUsersAndOrders() { DataTableJoinVertex users = this.graph.AddVertex(this.dataSource.Users, "U"); DataTableJoinVertex orders = this.graph.AddVertex(this.dataSource.Orders, "O"); DataRelationJoinEdge uo = this.graph.AddEdge(users, orders, JoinType.Inner); algo = new DataTableJoinSortAlgorithm(this.graph); algo.Compute(); Assert.IsNotNull(algo.StartVertex); Assert.AreEqual(1, algo.Joins.Count); ShowJoins(); }
protected void ShowJoins() { DataTableJoinVertex v = this.algo.StartVertex; Console.WriteLine("{0} AS {1}", v.Table.TableName, v.Alias); foreach (DataRelationJoinEdge edge in algo.Joins) { DataTableJoinVertex next = null; if (edge.Source == v) { next = (DataTableJoinVertex)edge.Target; } else { next = (DataTableJoinVertex)edge.Source; } Console.WriteLine("{0} JOIN {1} AS {2} ON ", edge.JoinType.ToString().ToUpper(), next.Table.TableName, next.Alias ); bool needAnd = false; for (int i = 0; i < edge.Relation.ParentColumns.Length; ++i) { if (needAnd) { Console.Write(" AND"); } else { needAnd = true; } Console.Write(" {0}.{1} = {2}.{3}", edge.Source.Alias, edge.Relation.ParentColumns[i].ColumnName, edge.Target.Alias, edge.Relation.ChildColumns[i].ColumnName ); } Console.WriteLine(); v = next; } }