Пример #1
0
 public void TestSqlTransactionForBatchQueryAsync()
 {
     using (var connection = new NpgsqlConnection(Database.ConnectionString))
     {
         // Prepare
         using (var transaction = connection.EnsureOpen().BeginTransaction())
         {
             // Act
             connection.BatchQueryAsync <CompleteTable>(0, 10, OrderField.Parse(new { Id = Order.Ascending }), it => it.Id != 0, transaction: transaction).Wait();
         }
     }
 }
Пример #2
0
        public void ThrowExceptionOnPostgreSqlConnectionBatchQueryAsyncWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                connection.BatchQueryAsync <CompleteTable>(0,
                                                           3,
                                                           OrderField.Ascending <CompleteTable>(c => c.Id).AsEnumerable(),
                                                           (object)null,
                                                           hints: "WhatEver").Wait();
            }
        }
Пример #3
0
        public void TestPostgreSqlConnectionBatchQueryAsyncThirdBatchDescending()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.BatchQueryAsync <CompleteTable>(2,
                                                                        3,
                                                                        OrderField.Descending <CompleteTable>(c => c.Id).AsEnumerable(),
                                                                        (object)null).Result;

                // Assert
                Helper.AssertPropertiesEquality(tables.ElementAt(3), result.ElementAt(0));
                Helper.AssertPropertiesEquality(tables.ElementAt(1), result.ElementAt(2));
            }
        }
Пример #4
0
        public void TestPostgreSqlConnectionBatchQueryViaTableNameAsyncThirdBatchAscending()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.BatchQueryAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                                        2,
                                                        3,
                                                        OrderField.Ascending <CompleteTable>(c => c.Id).AsEnumerable(),
                                                        (object)null).Result;

                // Assert
                Helper.AssertMembersEquality(tables.ElementAt(6), result.ElementAt(0));
                Helper.AssertMembersEquality(tables.ElementAt(8), result.ElementAt(2));
            }
        }