Beispiel #1
0
        public void SetParameterValuesGeneric()
        {
            var category = new Category {
                CategoryName = "Test",
                Description  = "FluentUtil"
            };

            // delete exist category
            NorthwindAdoRepository.ExecuteNonQueryBySqlString(
                @"DELETE FROM Categories where CategoryName = @CategoryName",
                new AdoParameter("CategoryName", category.CategoryName, DbType.String, 255));

            // insert
            using (var command = NorthwindAdoRepository.GetProcedureCommand("SaveOrUpdateCategory", true)) {
                AdoTool.SetParameterValues(NorthwindAdoRepository.Db,
                                           command,
                                           category,
                                           command.Mapping(NameMappingUtil.CapitalizeMappingFunc('_', ' ')));


                category.CategoryId = NorthwindAdoRepository.ExecuteCommand(command).AsInt(-1);
                Assert.AreNotEqual(-1, category.CategoryId);
            }

            // update
            using (var command = NorthwindAdoRepository.GetProcedureCommand("SaveOrUpdateCategory", true)) {
                AdoTool.SetParameterValues(NorthwindAdoRepository.Db,
                                           command,
                                           category,
                                           command.Mapping(NameMappingUtil.CapitalizeMappingFunc('_', ' ')));

                category.CategoryId = NorthwindAdoRepository.ExecuteCommand(command).AsInt(-1);
                Assert.AreNotEqual(-1, category.CategoryId);
            }
        }
 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 ExecuteDataTableAsList_ByProcedure()
        {
            using (var cmd = NorthwindAdoRepository.GetProcedureCommand("OrderAndOrderDetails")) {
                var tables = NorthwindAdoRepository.ExecuteDataTableAsList(cmd).ToList();

                Assert.AreEqual(2, tables.Count);
                tables.All(table => table.HasErrors == false).Should().Be.True();
            }
        }
Beispiel #4
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);
            }
        }