public void SingleUnion() { CustomerCollection coll = new CustomerCollection(); coll.es.Connection.Name = "ForeignKeyTest"; CustomerQuery cq1 = new CustomerQuery("c1"); cq1.SelectAllExcept(cq1.Notes); cq1.Where(cq1.DateAdded.Between(Convert.ToDateTime("2005-01-01"), Convert.ToDateTime("2005-12-31"))); CustomerQuery cq2 = new CustomerQuery("c2"); cq2.SelectAllExcept(cq2.Notes); cq2.Where(cq2.DateAdded.Between(Convert.ToDateTime("2006-01-01"), Convert.ToDateTime("2006-12-31"))); // Combine 2005 and 2006 in one result set cq1.Union(cq2); //string lq = cq1.Parse(); Assert.IsTrue(coll.Load(cq1)); Assert.AreEqual(49, coll.Count); }
public void SingleIntersect() { CustomerCollection coll = new CustomerCollection(); coll.es.Connection.Name = "ForeignKeyTest"; CustomerQuery cq1 = new CustomerQuery("c1"); cq1.SelectAllExcept(cq1.Notes); cq1.Where(cq1.DateAdded.Between(Convert.ToDateTime("2005-01-01"), Convert.ToDateTime("2005-12-31"))); CustomerQuery cq2 = new CustomerQuery("c2"); cq2.SelectAllExcept(cq2.Notes); cq2.Where(cq2.DateAdded.Between(Convert.ToDateTime("2005-12-31"), Convert.ToDateTime("2006-12-31"))); // Only the 2 rows for 2005-12-31 cq1.Intersect(cq2); Assert.IsTrue(coll.Load(cq1)); Assert.AreEqual(2, coll.Count); }
public void SingleIntersectWithNoOverlap() { CustomerCollection coll = new CustomerCollection(); coll.es.Connection.Name = "ForeignKeyTest"; CustomerQuery cq1 = new CustomerQuery("c1"); cq1.SelectAllExcept(cq1.Notes); cq1.Where(cq1.DateAdded.Between(Convert.ToDateTime("2005-01-01"), Convert.ToDateTime("2005-12-31"))); CustomerQuery cq2 = new CustomerQuery("c2"); cq2.SelectAllExcept(cq2.Notes); cq2.Where(cq2.DateAdded.Between(Convert.ToDateTime("2006-01-01"), Convert.ToDateTime("2006-12-31"))); // There is no intersection for 2005 and 2006 cq1.Intersect(cq2); Assert.IsFalse(coll.Load(cq1)); Assert.AreEqual(0, coll.Count); }
public void SingleExceptWithNoOverlap() { CustomerCollection coll = new CustomerCollection(); coll.es.Connection.Name = "ForeignKeyTest"; CustomerQuery cq1 = new CustomerQuery("c1"); cq1.SelectAllExcept(cq1.Notes); cq1.Where(cq1.DateAdded.Between(Convert.ToDateTime("2005-01-01"), Convert.ToDateTime("2006-12-31"))); CustomerQuery cq2 = new CustomerQuery("c2"); cq2.SelectAllExcept(cq2.Notes); cq2.Where(cq2.DateAdded == Convert.ToDateTime("1900-12-31")); // All 2005 and 2006 cq1.Except(cq2); Assert.IsTrue(coll.Load(cq1)); Assert.AreEqual(49, coll.Count); }