public void ThrowExceptionOnMySqlConnectionCountAsyncWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.CountAsync <CompleteTable>((object)null, hints: "WhatEver").Wait(); } }
public void TestSqlTransactionForCountAsync() { using (var connection = new MySqlConnection(Database.ConnectionString)) { // Prepare using (var transaction = connection.EnsureOpen().BeginTransaction()) { // Act connection.CountAsync <CompleteTable>(it => it.Id != 0, transaction: transaction).Wait(); } } }
public void ThrowExceptionOnMySqlConnectionCountAsyncViaTableNameWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.CountAsync(ClassMappedNameCache.Get <CompleteTable>(), (object)null, hints: "WhatEver").Wait(); } }
public void TestMySqlConnectionCountAsyncViaQueryField() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.CountAsync <CompleteTable>(new QueryField("Id", tables.First().Id)).Result; // Assert Assert.AreEqual(tables.Where(e => e.Id == tables.First().Id).Count(), result); } }
public void TestMySqlConnectionCountAsyncWithoutExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.CountAsync <CompleteTable>((object)null).Result; // Assert Assert.AreEqual(tables.Count(), result); } }
public void TestMySqlConnectionCountAsyncViaTableNameViaDynamic() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.CountAsync(ClassMappedNameCache.Get <CompleteTable>(), new { tables.First().Id }).Result; // Assert Assert.AreEqual(tables.Where(e => e.Id == tables.First().Id).Count(), result); } }
public void TestMySqlConnectionCountAsyncViaExpression() { // Setup var tables = Database.CreateCompleteTables(10); var ids = new[] { tables.First().Id, tables.Last().Id }; using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.CountAsync <CompleteTable>(e => ids.Contains(e.Id)).Result; // Assert Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Count(), result); } }
public void TestMySqlConnectionCountAsyncViaQueryFields() { // 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 MySqlConnection(Database.ConnectionString)) { // Act var result = connection.CountAsync <CompleteTable>(queryFields).Result; // Assert Assert.AreEqual(tables.Where(e => e.Id > tables.First().Id&& e.Id < tables.Last().Id).Count(), result); } }