Exemple #1
0
        public void LoadDataSetByParallelForEach()
        {
            var options = new ParallelOptions {
                MaxDegreeOfParallelism = DegreeOfParallelism
            };

            Parallel.ForEach(Sections2,
                             options,
                             (section, loopState) => {
                var query = NorthwindAdoRepository.QueryProvider.GetQuery(section, QueryName);

                using (var cmd = NorthwindAdoRepository.GetCommand(query)) {
                    var ds = NorthwindAdoRepository.ExecuteDataSet(cmd);
                    Assert.AreEqual(1, ds.Tables.Count);
                    Assert.IsFalse(ds.Tables[0].HasErrors);

                    if (IsDebugEnabled)
                    {
                        log.Debug("[{0}] Table을 로드하는데 성공했습니다.", ds.Tables[0].TableName);
                    }

                    ds.Dispose();
                }
            });
        }
        public void ExecuteDataSetInTransactionScope()
        {
            Action <int, int> loadMethod = (firstResult, maxResults) => {
                using (var cmd = NorthwindAdoRepository.GetCommand(GetOrderDetailsSql))
                    using (var ds = NorthwindAdoRepository.ExecuteDataSet(cmd, 5, 5)) {
                        Assert.AreEqual(ds.Tables.Count, 1);
                        Assert.Greater(ds.Tables[0].Rows.Count, 1);
                        Console.WriteLine("RowCount: " + ds.Tables[0].Rows.Count);
                    }
            };

            AdoWith.TransactionScope(delegate {
                loadMethod(5, 10);
                loadMethod(5, 5);
                loadMethod(1, 1);
            },
                                     delegate {
                loadMethod(5, 10);
                loadMethod(5, 5);
                loadMethod(1, 1);
            },
                                     delegate {
                loadMethod(5, 10);
                loadMethod(5, 5);
                loadMethod(1, 1);
            });
        }
        public void ExecuteDataSet(int firstResult, int maxResults)
        {
            DataSet ds;

            using (var cmd = NorthwindAdoRepository.GetCommand(GetOrderDetailsSql))
                using (ds = NorthwindAdoRepository.ExecuteDataSet(cmd, firstResult, maxResults)) {
                    Assert.AreEqual(ds.Tables.Count, 1);
                    Assert.IsFalse(ds.Tables[0].HasErrors);
                    Assert.Greater(ds.Tables[0].Rows.Count, 1);
                    Console.WriteLine("RowCount: " + ds.Tables[0].Rows.Count);
                }

            using (ds = NorthwindAdoRepository
                        .ExecuteDataSetBySqlString(GetOrderByOrderDateAndFreightAndCustomerSql,
                                                   firstResult,
                                                   maxResults,
                                                   new AdoParameter("OrderDate", DateTime.Today),
                                                   new AdoParameter("Freight", 2),
                                                   CustomerTestParameter)) {
                Assert.AreEqual(ds.Tables.Count, 1);
                Assert.IsFalse(ds.Tables[0].HasErrors);
                // Assert.Greater(ds.Tables[0].Rows.Count, 1);
                Console.WriteLine("RowCount: " + ds.Tables[0].Rows.Count);
            }
        }
 public void ExecuteDataSet_MultiResultSet_ByProcedure()
 {
     using (var cmd = NorthwindAdoRepository.GetProcedureCommand("OrderAndOrderDetails")) {
         using (var ds = NorthwindAdoRepository.ExecuteDataSet(cmd)) {
             ds.Tables.Count.Should().Be(2);
             ds.Tables.Cast <DataTable>().All(table => table.HasErrors == false).Should().Be.True();
         }
     }
 }
        public void ExecuteDataSet_MultiResultSet_BySqlString()
        {
            var sql = string.Concat(GetOrdersSql, ";", GetOrderDetailsSql);

            using (var cmd = NorthwindAdoRepository.GetSqlStringCommand(sql))
                using (var ds = NorthwindAdoRepository.ExecuteDataSet(cmd)) {
                    Assert.AreEqual(2, ds.Tables.Count);
                    ds.Tables.Cast <DataTable>().All(table => table.HasErrors == false).Should().Be.True();
                }
        }
        public void ExecuteDataSetByQuery(int firstResult, int maxResults)
        {
            DataSet ds = null;

            using (ds = NorthwindAdoRepository.ExecuteDataSet(GetOrderDetailsSql, firstResult, maxResults)) {
                Assert.AreEqual(ds.Tables.Count, 1);
                Assert.IsFalse(ds.Tables[0].HasErrors);
                Assert.Greater(ds.Tables[0].Rows.Count, 1);
                Console.WriteLine("RowCount: " + ds.Tables[0].Rows.Count);
            }
        }
        public void ExecuteDataSetByPaging(int firstResult, int maxResults)
        {
            DataSet ds = null;

            using (var cmd = NorthwindAdoRepository.GetCommand(GetOrderDetailsSql))
                using (ds = NorthwindAdoRepository.ExecuteDataSet(cmd, firstResult, maxResults)) {
                    Assert.AreEqual(ds.Tables.Count, 1);
                    Assert.Greater(ds.Tables[0].Rows.Count, 0);
                    Console.WriteLine("RowCount=[{0}]", ds.Tables[0].Rows.Count);
                }

            using (ds = NorthwindAdoRepository.ExecuteDataSetBySqlString(GetOrderDetailsSql, firstResult, maxResults)) {
                Assert.AreEqual(ds.Tables.Count, 1);
                Assert.Greater(ds.Tables[0].Rows.Count, 0);
                Console.WriteLine("RowCount=[{0}]", ds.Tables[0].Rows.Count);
            }
        }
Exemple #8
0
        public void LoadDataSetBySerial()
        {
            foreach (var section in Sections2)
            {
                var queryKey = section + "," + QueryName;

                var ds = NorthwindAdoRepository.ExecuteDataSet(queryKey);
                Assert.AreEqual(1, ds.Tables.Count);
                Assert.IsFalse(ds.Tables[0].HasErrors);

                if (IsDebugEnabled)
                {
                    log.Debug("[{0}] Table을 로드하는데 성공했습니다.", ds.Tables[0].TableName);
                }

                ds.Dispose();
            }
        }
Exemple #9
0
        public void ExecuteDataSetByProcedure()
        {
            var spName = NorthwindAdoRepository.QueryProvider.GetQuery("Order, CustomerOrderHistory");

            using (var cmd = NorthwindAdoRepository.GetProcedureCommand(spName)) {
                using (var ds = NorthwindAdoRepository.ExecuteDataSet(cmd, CustomerTestParameter)) {
                    Assert.AreEqual(ds.Tables.Count, 1);
                    Assert.IsFalse(ds.Tables[0].HasErrors);
                    Assert.Greater(ds.Tables[0].Rows.Count, 0);
                }
            }

            spName = NorthwindAdoRepository.QueryProvider.GetQuery("CustomerOrdersDetail");
            using (var ds = NorthwindAdoRepository.ExecuteDataSetByProcedure(spName, OrderTestParameter)) {
                Assert.AreEqual(ds.Tables.Count, 1);
                Assert.IsFalse(ds.Tables[0].HasErrors);
                Assert.Greater(ds.Tables[0].Rows.Count, 0);
            }
        }
Exemple #10
0
        public void Can_Serial_ExecuteDataSet()
        {
            // 여러 테이블의 정보를 비동기적으로 거의 동시에 로드합니다.
            foreach (var section in Sections2)
            {
                var query = NorthwindAdoRepository.QueryProvider.GetQuery(section, QueryKey);
                Assert.IsNotEmpty(query);

                var dataset = NorthwindAdoRepository.ExecuteDataSet(query);

                Assert.AreEqual(1, dataset.Tables.Count);
                Assert.IsFalse(dataset.Tables[0].HasErrors);

                if (IsDebugEnabled)
                {
                    log.Debug("Table[{0}] has [{1}] rows", dataset.Tables[0].TableName, dataset.Tables[0].Rows.Count);
                }

                dataset.Dispose();
            }
        }
Exemple #11
0
        public void LoadDataSetByPLinqForAll()
        {
            //var results = new ConcurrentDictionary<string, DataSet>();

            //Sections2
            // .Do(section => log.Debug("이건 LINQ 작업을 확인하기 위한 함수입니다... ㅋㅋ... 지금 수행하고자 하는 Table은 " + section + "입니다."))
            //.AsParallel()
            //.WithDegreeOfParallelism(DegreeOfParallelism)
            //.ForAll(section =>
            Parallel.ForEach(Sections2,
                             section => {
                var query = NorthwindAdoRepository.QueryProvider.GetQuery(section, QueryName);
                using (var cmd = NorthwindAdoRepository.GetCommand(query))
                    using (var ds = NorthwindAdoRepository.ExecuteDataSet(cmd)) {
                        Assert.AreEqual(1, ds.Tables.Count);
                        Assert.IsFalse(ds.Tables[0].HasErrors);

                        if (IsDebugEnabled)
                        {
                            log.Debug("[{0}] Table을 로드하는데 성공했습니다.", ds.Tables[0].TableName);
                        }
                    }
            });
        }