public void TestMySqlConnectionAverageWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.Average <CompleteTable>(e => e.ColumnInt, (object)null, hints: "WhatEver"); } }
public void TestMySqlConnectionAverageViaTableNameWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.Average(ClassMappedNameCache.Get <CompleteTable>(), Field.Parse <CompleteTable>(e => e.ColumnInt).First(), (object)null, hints: "WhatEver"); } }
public void TestMySqlConnectionAverageWithoutExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.Average <CompleteTable>(e => e.ColumnInt, (object)null); // Assert Assert.AreEqual(tables.Average(e => e.ColumnInt), Convert.ToDouble(result)); } }
public void TestMySqlConnectionAverageWithExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var ids = new[] { tables.First().Id, tables.Last().Id }; var result = connection.Average <CompleteTable>(e => e.ColumnInt, e => ids.Contains(e.Id)); // Assert Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInt), Convert.ToDouble(result)); } }
public void TestMySqlConnectionAverageViaTableNameWithoutExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.Average(ClassMappedNameCache.Get <CompleteTable>(), Field.Parse <CompleteTable>(e => e.ColumnInt).First(), (object)null); // Assert Assert.AreEqual(tables.Average(e => e.ColumnInt), Convert.ToDouble(result)); } }
public void TestMySqlConnectionAverageViaTableNameWithExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var ids = new[] { tables.First().Id, tables.Last().Id }; var result = connection.Average(ClassMappedNameCache.Get <CompleteTable>(), Field.Parse <CompleteTable>(e => e.ColumnInt).First(), new QueryField("Id", Operation.In, ids)); // Assert Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInt), Convert.ToDouble(result)); } }