public void LeftWithOperatorsInOn() { int record = 0; CustomerCollection collection = new CustomerCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); switch (collection.es.Connection.ProviderSignature.DataProviderName) { //case "EntitySpaces.NpgsqlProvider": //case "EntitySpaces.Npgsql2Provider": case "EntitySpaces.OracleClientProvider": record = 2; CustomerQuery cq = new CustomerQuery("cq"); EmployeeQuery eq = new EmployeeQuery("eq"); cq.Select(cq.CustomerName, eq.LastName); cq.LeftJoin(eq).On(cq.StaffAssigned == eq.EmployeeID & eq.Supervisor == 1); cq.OrderBy(cq.CustomerName.Ascending); Assert.IsTrue(collection.Load(cq)); Assert.AreEqual(56, collection.Count); Assert.AreEqual("Doe", collection[record].GetColumn("LastName")); break; default: record = 1; cq = new CustomerQuery("cq"); eq = new EmployeeQuery("eq"); cq.Select(cq.CustomerName, eq.LastName); cq.LeftJoin(eq).On(cq.StaffAssigned == eq.EmployeeID & eq.Supervisor == 1); cq.OrderBy(cq.CustomerName.Ascending); Assert.IsTrue(collection.Load(cq)); Assert.AreEqual(56, collection.Count); Assert.AreEqual("Doe", collection[record].GetColumn("LastName")); break; } }
public void LoadJoined() { CustomerQuery cq = new CustomerQuery("c"); EmployeeQuery eq = new EmployeeQuery("e"); EmployeeQuery eq2 = new EmployeeQuery("e2"); OrderQuery oq = new OrderQuery("o"); OrderItemQuery oiq = new OrderItemQuery("oi"); ProductQuery pq = new ProductQuery("p"); cq.Select( cq.CustomerID, cq.CustomerSub, cq.CustomerName, eq, eq2.LastName.As("ReportsTo"), oq.PlacedBy, oq.OrderDate, oiq, pq.ProductName, pq.Discontinued); cq.LeftJoin(eq).On(eq.EmployeeID == cq.Manager); cq.LeftJoin(eq2).On(eq.Supervisor == eq2.EmployeeID); cq.LeftJoin(oq).On(cq.CustomerID == oq.CustID && cq.CustomerSub == oq.CustSub); cq.LeftJoin(oiq).On(oq.OrderID == oiq.OrderID); cq.LeftJoin(pq).On(oiq.ProductID == pq.ProductID); CustomerCollection coll = new CustomerCollection(); coll.es.Connection.Name = "ForeignKeyTest"; Assert.IsTrue(coll.Load(cq)); Assert.AreEqual(69, coll.Count); }
public void LeftWithWhere() { CustomerCollection collection = new CustomerCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); CustomerQuery cust = new CustomerQuery("cq"); EmployeeQuery emp = new EmployeeQuery("eq"); cust.Select(cust.CustomerID, emp.LastName, cust.Manager, cust.StaffAssigned); cust.LeftJoin(emp).On(cust.Manager == emp.EmployeeID); cust.Where( cust.Manager == cust.StaffAssigned); Assert.IsTrue(collection.Load(cust)); Assert.AreEqual(4, collection.Count); }