예제 #1
0
        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");
            }
        }
예제 #2
0
        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");
            }
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        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));
            }
        }
예제 #5
0
        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));
            }
        }
예제 #6
0
        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));
            }
        }