コード例 #1
0
        public void Load_MultipleResultSet()
        {
            var tables = new List <DataTable>();

            var sqlString = string.Concat(SQL_ORDER_SELECT, ";", SQL_ORDER_DETAIL_SELECT);

            using (var adapter = new AdoDataAdapter(NorthwindAdoRepository.GetDataAdapter()))
                using (var reader = NorthwindAdoRepository.ExecuteReaderBySqlString(sqlString)) {
                    do
                    {
                        var table = new DataTable();
                        adapter.Fill(new[] { table }, reader, 0, 0);

                        tables.Add(table);
                    } while(reader.IsClosed == false && reader.NextResult());
                }

            Assert.AreEqual(2, tables.Count);
            tables.All(table => table.HasErrors == false);
            tables.RunEach(table => {
                Assert.Greater(table.Rows.Count, 0);
                if (IsDebugEnabled)
                {
                    log.Debug(table.CreateDataReader().ToString(true));
                }
            });
        }
コード例 #2
0
        public void Load_CustomerOrderHistory()
        {
            using (var adapter = new AdoDataAdapter(NorthwindAdoRepository.GetDataAdapter()))
                using (var reader = CustomerOrderDetailDataReader()) {
                    Assert.IsNotNull(reader);
                    Assert.Greater(reader.FieldCount, 0);

                    var dataTable = new DataTable();

                    adapter.Fill(new[] { dataTable }, reader, 5, 10);

                    Assert.IsFalse(dataTable.HasErrors);
                    Assert.AreEqual(10, dataTable.Rows.Count);
                }
        }
コード例 #3
0
        public void Load_Nullable()
        {
            var spName = NorthwindAdoRepository.QueryProvider.GetQuery("TenMostExpensiveProduct");

            using (var adapter = new AdoDataAdapter(NorthwindAdoRepository.GetDataAdapter()))
                using (var reader = NorthwindAdoRepository.ExecuteReaderByProcedure(spName)) {
                    Assert.IsNotNull(reader);

                    var dataTable = new DataTable();

                    adapter.Fill(new[] { dataTable }, reader, 2, 2);

                    Assert.IsFalse(dataTable.HasErrors);
                    Assert.AreEqual(2, dataTable.Rows.Count);
                }
        }
コード例 #4
0
        public void Load_TenMostExpensiveProduct()
        {
            var spName = NorthwindAdoRepository.QueryProvider.GetQuery("TenMostExpensiveProduct");

            Assert.IsNotEmpty(spName);

            if (IsDebugEnabled)
            {
                log.Debug("Execute Procedure... spName=[{0}]", spName);
            }

            using (var adapter = new AdoDataAdapter(NorthwindAdoRepository.GetDataAdapter()))
                using (var reader = NorthwindAdoRepository.ExecuteReaderByProcedure(spName)) {
                    Assert.IsNotNull(reader);
                    Assert.Greater(reader.FieldCount, 0);

                    var dataTable = new DataTable();
                    adapter.Fill(new[] { dataTable }, reader, 2, 2);

                    Assert.IsFalse(dataTable.HasErrors);
                    Assert.AreEqual(2, dataTable.Rows.Count);
                }
        }