コード例 #1
0
        public void TestMySqlConnectionAverageAsyncWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                connection.AverageAsync <CompleteTable>(e => e.ColumnInt,
                                                        (object)null,
                                                        hints: "WhatEver").Wait();
            }
        }
コード例 #2
0
        public void TestMySqlConnectionAverageAsyncViaTableNameWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                connection.AverageAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                        Field.Parse <CompleteTable>(e => e.ColumnInt).First(),
                                        (object)null,
                                        hints: "WhatEver").Wait();
            }
        }
コード例 #3
0
        public void TestMySqlConnectionAverageAsyncWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.AverageAsync <CompleteTable>(e => e.ColumnInt,
                                                                     (object)null).Result;

                // Assert
                Assert.AreEqual(tables.Average(e => e.ColumnInt), Convert.ToDouble(result));
            }
        }
コード例 #4
0
        public void TestMySqlConnectionAverageAsyncViaTableNameWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.AverageAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                                     Field.Parse <CompleteTable>(e => e.ColumnInt).First(),
                                                     (object)null).Result;

                // Assert
                Assert.AreEqual(tables.Average(e => e.ColumnInt), Convert.ToDouble(result));
            }
        }
コード例 #5
0
        public void TestMySqlConnectionAverageAsyncWithExpression()
        {
            // 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.AverageAsync <CompleteTable>(e => e.ColumnInt,
                                                                     e => ids.Contains(e.Id)).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInt), Convert.ToDouble(result));
            }
        }
コード例 #6
0
        public void TestMySqlConnectionAverageAsyncViaTableNameWithExpression()
        {
            // 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.AverageAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                                     Field.Parse <CompleteTable>(e => e.ColumnInt).First(),
                                                     new QueryField("Id", Operation.In, ids)).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInt), Convert.ToDouble(result));
            }
        }