public void WhereExpressionMethodConstParameter() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).Any(GetNameEndsWith("er"))); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Manager, ContactType.Customer }, te); } }
public void AnyFiltered() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Any(c => c.Type == t && c.LastSalary.Value == 123)); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Customer }, te); } }
public void WhereExpressionProperty() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(SalaryIs345).Any(c => c.Type == t)); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Employee }, te); } }
public void SingleOrDefaultFiltered() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().SingleOrDefault(c => c.Type == t && c.LastSalary.Value < 0) != null); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Customer }, te); } }
public void FirstOrDefault() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).Select(c => c.Name).FirstOrDefault().EndsWith("er")); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Manager, ContactType.Customer }, te); } }
public void OrderByGetLabelNone() { using (new SoodaTransaction()) { IEnumerable <ContactType> ce = ContactType.Linq().OrderBy(t => t.GetLabel(false)); CollectionAssert.AreEquivalent(ContactType.GetList(true), ce); } }
public void FirstOrDefaultFiltered() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).FirstOrDefault(c => c.Name.EndsWith("er")) == null); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Employee }, te); } }
public void SelectSum() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).Select(c => c.LastSalary.Value).Sum() == 234 + 345); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Employee }, te); } }
public void SumEmpty() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t && c.ContactId > 1).Sum(c => c.LastSalary.Value) == 0); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Manager }, te); } }
public void SelectAverageIntFractional() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).Select(c => c.ContactId).Average() == 51.5); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Customer }, te); } }
public void Contains() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).Contains(Contact.Ed)); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Employee }, te); } }
public void TypeIs() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Any(c => TypeIs(c, t) && c.LastSalary.Value == 345)); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Employee }, te); } }
public void All() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Where(c => c.Type == t).All(c => c.LastSalary.Value > 100)); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Manager, ContactType.Employee }, te); } }
public void CountFiltered() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => Contact.Linq().Count(c => c.Type == t) > 1); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Employee, ContactType.Customer }, te); } }
public void AnyUnion() { using (new SoodaTransaction()) { var q1 = ContactType.Linq().Where(t => Contact.Linq().Any(c => c.Type == t && c.LastSalary.Value == 123)); var q2 = ContactType.Linq().Where(t => Contact.Linq().Any(c => c.Type == t && c.LastSalary.Value == 345)); IEnumerable <ContactType> te = q1.Union(q2); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Customer, ContactType.Employee }, te); } }
public void FirstOrDefaultNullableDecimal() { using (new SoodaTransaction()) { IEnumerable <ContactType> te = ContactType.Linq().Where(t => (from c in Contact.Linq() where c.Type == t && c.LastSalary.Value > 123 select c.LastSalary).FirstOrDefault().IsNull); CollectionAssert.AreEquivalent(new ContactType[] { ContactType.Customer }, te); } }
public void LastOrDefaultFiltered() { using (new SoodaTransaction()) { IEnumerable <Contact> ce = from t in ContactType.Linq() orderby t.Code select Contact.Linq().OrderBy(c => c.LastSalary.Value).LastOrDefault(c => c.Type == t); CollectionAssert.AreEqual(new Contact[] { Contact.GetRef(52), Contact.Eva, Contact.Mary }, ce); } }
public void GetLabelNone() { using (new SoodaTransaction()) { string[] sa = ContactType.Linq().Select(t => t.GetLabel(false)).ToArray(); Assert.AreEqual(3, sa.Length); Assert.IsNull(sa[0]); Assert.IsNull(sa[1]); Assert.IsNull(sa[2]); int c = ContactType.Linq().Count(t => t.GetLabel(false) == null); Assert.AreEqual(3, c); } }
public void LastOrDefault() { using (new SoodaTransaction()) { IEnumerable <string> se = from t in ContactType.Linq() orderby t.Code select (from c in Contact.Linq() where c.Type == t orderby c.LastSalary.Value select c.Name).LastOrDefault(); CollectionAssert.AreEqual(new string[] { "Chris Customer", "Eva Employee", "Mary Manager" }, se); } }
public void TopSalaries() { using (new SoodaTransaction()) { var l = (from t in ContactType.Linq() orderby Contact.Linq().Where(c => c.Type == t).Max(c => c.LastSalary.Value) descending select new { ContactType = t.Code, TopSalary = Contact.Linq().Where(c => c.Type == t).Max(c => c.LastSalary.Value), MostPaid = (from c in Contact.Linq() where c.Type == t orderby c.LastSalary.Value descending select c.Name).FirstOrDefault() }).ToList(); CollectionAssert.AreEqual(new string[] { "Employee", "Manager", "Customer" }, l.Select(o => o.ContactType)); CollectionAssert.AreEqual(new decimal[] { 345M, 123.123456789M, 123M }, l.Select(o => o.TopSalary)); CollectionAssert.AreEqual(new string[] { "Eva Employee", "Mary Manager", "Chris Customer" }, l.Select(o => o.MostPaid)); } }