public void WhereExistsANDedTogether() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); EmployeeQuery eq1 = new EmployeeQuery("e1"); EmployeeQuery eq2 = new EmployeeQuery("e2"); EmployeeQuery eq3 = new EmployeeQuery("e3"); eq1.Where(eq1.Exists(eq2), eq1.Exists(eq3)); Assert.IsTrue(collection.Load(eq1)); Assert.AreEqual(5, collection.Count); string lq = collection.Query.es.LastQuery; string[] one = lq.Split('1'); Assert.AreEqual(2, one.GetLength(0)); string[] two = lq.Split('2'); Assert.AreEqual(2, two.GetLength(0)); string[] three = lq.Split('3'); Assert.AreEqual(2, three.GetLength(0)); }
public void WhereExists() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); // SubQuery of Employees with a null Supervisor column. EmployeeQuery sq = new EmployeeQuery("s"); sq.es.Distinct = true; sq.Select(sq.EmployeeID); sq.Where(sq.Supervisor.IsNull()); // If even one employee has a null supervisor, // i.e., the above query has a result set, // then run a list of all employees. EmployeeQuery eq = new EmployeeQuery("e"); eq.Select(eq.EmployeeID, eq.Supervisor); eq.Where(eq.Exists(sq)); Assert.IsTrue(collection.Load(eq)); Assert.AreEqual(5, collection.Count); }
public void WhereExistsFalse() { EmployeeCollection collection = new EmployeeCollection(); collection.es.Connection.ConnectionString = UnitTestBase.GetFktString(collection.es.Connection); // EmployeeID is required and will never be NULL EmployeeQuery sq = new EmployeeQuery("s"); sq.es.Distinct = true; sq .Select(sq.EmployeeID) .Where(sq.EmployeeID.IsNull()); // This should produce no results as the // inner query does not exist. EmployeeQuery eq = new EmployeeQuery("e"); eq .Select(eq.EmployeeID, eq.Supervisor) .Where(eq.Exists(sq)); Assert.IsFalse(collection.Load(eq)); }