public void ThrowExceptionOnPostgreSqlConnectionCountWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Act connection.Count <CompleteTable>((object)null, hints: "WhatEver"); } }
public void TestSqlTransactionForCount() { using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Prepare using (var transaction = connection.EnsureOpen().BeginTransaction()) { // Act connection.Count <CompleteTable>(it => it.Id != 0, transaction: transaction); } } }
public void TestPostgreSqlConnectionCountViaQueryField() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Act var result = connection.Count <CompleteTable>(new QueryField("Id", tables.First().Id)); // Assert Assert.AreEqual(tables.Where(e => e.Id == tables.First().Id).Count(), result); } }
public void TestPostgreSqlConnectionCountWithoutExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Act var result = connection.Count <CompleteTable>((object)null); // Assert Assert.AreEqual(tables.Count(), result); } }
public void TestPostgreSqlConnectionCountViaExpression() { // Setup var tables = Database.CreateCompleteTables(10); var ids = new[] { tables.First().Id, tables.Last().Id }; using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Act var result = connection.Count <CompleteTable>(e => ids.Contains(e.Id)); // Assert Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Count(), result); } }
public void TestPostgreSqlConnectionCountViaTableNameViaDynamic() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Act var result = connection.Count(ClassMappedNameCache.Get <CompleteTable>(), new { tables.First().Id }); // Assert Assert.AreEqual(tables.Where(e => e.Id == tables.First().Id).Count(), result); } }
public void TestPostgreSqlConnectionCountViaQueryFields() { // Setup var tables = Database.CreateCompleteTables(10); var queryFields = new[] { new QueryField("Id", Operation.GreaterThan, tables.First().Id), new QueryField("Id", Operation.LessThan, tables.Last().Id) }; using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Act var result = connection.Count <CompleteTable>(queryFields); // Assert Assert.AreEqual(tables.Where(e => e.Id > tables.First().Id&& e.Id < tables.Last().Id).Count(), result); } }