public void CountWithPredicateTest() { var count = Session.Query.All <Invoice>().Count(o => o.InvoiceId > 10); var expected = Invoices.Count(o => o.InvoiceId > 10); Assert.AreEqual(expected, count); Assert.Greater(count, 0); }
public void QueryTest() { var expected = Invoices.Count(); var result = Session.Query.All <IHasCommission>().ToList(); Assert.AreEqual(expected, result.Count); Assert.IsTrue(result.All(i => i != null)); }
public void SimpleWithResultSelectorTest() { var expected = Invoices.Count(); var result = Session.Query.All <Customer>() .SelectMany(c => Session.Query.All <Invoice>().Where(i => i.Customer == c), (c, i) => new { c, i }); Assert.That(result, Is.Not.Empty); Assert.AreEqual(expected, result.ToList().Count); }
public void SimpleTest() { int expected = Invoices.Count(); IQueryable <Invoice> result = Session.Query.All <Customer>() .SelectMany(c => Session.Query.All <Invoice>().Where(i => i.Customer == c)); Assert.That(result, Is.Not.Empty); Assert.AreEqual(expected, result.ToList().Count); }
public void EntitySetTest() { int expected = Invoices.Count(); IQueryable <Invoice> result = Session.Query.All <Customer>() .SelectMany(c => c.Invoices); Assert.That(result, Is.Not.Empty); Assert.AreEqual(expected, result.ToList().Count); }
public void SumCountTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var expected = Invoices.Count(); var count = Session.Query.All <Customer>() .Sum(c => Session.Query.All <Invoice>().Count(o => o.Customer == c)); Assert.AreEqual(expected, count); }
public void OrderByEnumTest() { var result = Session.Query.All <Invoice>().OrderBy(i => i.Status).ThenBy(i => i.InvoiceId); var list = result.ToList(); var expected = Invoices.OrderBy(i => i.Status).ThenBy(i => i.InvoiceId); Assert.That(list, Is.Not.Empty); Assert.AreEqual(Invoices.Count(), list.Count); Assert.IsTrue(expected.SequenceEqual(list)); }
public void MaxCountTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var result = Session.Query.All <Customer>() .Max(c => Session.Query.All <Invoice>().Count(o => o.Customer == c)); var expected = Customers .Max(c => Invoices.Count(o => o.Customer == c)); Assert.AreEqual(expected, result); }
public void CountTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var expected = Invoices.Count(); var count = Session.Query.All <Customer>() .Select(c => c.Invoices.Count) .ToList() .Sum(); Assert.AreEqual(expected, count); }
public void SelectCountTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe); var result = Session.Query.All <Customer>() .Select(c => Session.Query.All <Invoice>().Count()) .ToList(); var expected = Customers .Select(c => Invoices.Count()); Assert.AreEqual(0, expected.Except(result).Count()); Assert.Greater(result.Count, 0); }
public void WhereCountTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var result = Session.Query.All <Customer>() .Where(c => Session.Query.All <Invoice>().Count(o => o.Customer == c) > 5); var expected = Customers .Where(c => Invoices .Count(o => o.Customer == c) > 5); Assert.AreEqual(0, expected.Except(result).Count()); QueryDumper.Dump(result); Assert.Greater(result.ToList().Count, 0); }
public void ParameterTest() { var expectedCount = Invoices.Count(); var result = Session.Query.All <Customer>() .SelectMany(i => i.Invoices.Select(t => i)); Assert.That(result, Is.Not.Empty); Assert.AreEqual(expectedCount, result.Count()); foreach (var customer in result) { Assert.IsNotNull(customer); } }
public void SelectUsingContextTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var expectedCount = Invoices.Count(); var context = new Context(); var actualCount = context.Invoices.Count(); var list = context.Invoices.ToList(); Assert.AreEqual(expectedCount, actualCount); Assert.AreEqual(expectedCount, list.Count); var result = context.Customers.Where(c => context.Invoices.Count(i => i.Customer == c) > 5); Assert.Greater(result.ToList().Count, 0); }
public void WhereCountWithPredicateTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var result = from c in Session.Query.All <Customer>() where Session.Query.All <Invoice>().Count(o => o.Customer == c) > 6 select c; var expected = from c in Customers where Invoices .Count(o => o.Customer == c) > 6 select c; Assert.AreEqual(0, expected.Except(result).Count()); QueryDumper.Dump(result); Assert.Greater(result.ToList().Count, 0); }
public void SelectAnonymousCountTest() { Require.ProviderIsNot(StorageProvider.SqlServerCe | StorageProvider.Oracle); var result = from c in Session.Query.All <Customer>() select new { Customer = c, NumberOfOrders = Session.Query.All <Invoice>() .Count(o => o.Customer == c) }; var expected = from c in Customers select new { Customer = c, NumberOfOrders = Invoices .Count(o => o.Customer == c) }; Assert.AreEqual(0, expected.Except(result).Count()); QueryDumper.Dump(result); Assert.Greater(result.ToList().Count, 0); }
public int CalculateUserInvoices() { TotalUserInvoices += Invoices.Count(); return(TotalUserInvoices); }