컬럼명에서 '_', White Space 를 제외하고, Pascal 명명법에 따라 단어를 대문자로 사용한다. (예: PROJECT_NAME => ProjectName)
상속: NameMapperBase
예제 #1
0
        public void MapFromDataReader_OrderDetails_DynamicProxy() {
            var capitalizeNameMapper = new CapitalizeNameMapper();
            using(var reader = NorthwindAdoRepository.ExecuteReaderBySqlString(SQL_ORDER_DETAIL_SELECT)) {
                var orderDetails = reader.Map<OrderDetail>(DynamicProxyTool.CreateEditablePropertyChanged<OrderDetail>, CapitalizeMapper);

                Assert.Greater(orderDetails.Count, 0);

                orderDetails.All(od => od.OrderID > 0).Should().Be.True();
                orderDetails.All(od => od.ProductID > 0).Should().Be.True();
                orderDetails.All(od => od.Quantity > 0).Should().Be.True();
                orderDetails.All(od => od.Discount >= 0.0f).Should().Be.True();

                // 모든 엔티티가 Proxy 된 것입니다!!!
                orderDetails.All(od => od.IsDynamicProxy()).Should().Be.True();
            }
        }
        public void FluentByNameMapper_Load() {

            INameMapper nameMapper = new CapitalizeNameMapper();

            using(var cmd = AdoRepository.GetCommand(SP_CUSTOMER_ORDER_HISTORY)) {
                var orderHistories = AdoRepository.ExecuteInstance<CustomerOrderHistory>(nameMapper, cmd, CustomerTestParameter);

                Assert.Greater(orderHistories.Count, 0);
                CollectionAssert.AllItemsAreNotNull((ICollection)orderHistories);
                CollectionAssert.AllItemsAreInstancesOfType((ICollection)orderHistories, typeof(CustomerOrderHistory));
            }
        }
        public void FluentByNameMapper_Save() {
            INameMapper nameMapper = new CapitalizeNameMapper();

            var category = new Category
                           {
                               CategoryName = "Test",
                               Description = "FluentUtil"
                           };

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

            // insert
            var result = SQLiteRepository.ExecuteEntity("SaveOrUpdateCategory", category, nameMapper);

            category.CategoryId = result.AsInt(-1); //ConvertTool.DefValue(result, -1);
            Assert.AreNotEqual(-1, category.CategoryId);

            // update
            result = SQLiteRepository.ExecuteEntity("SaveOrUpdateCategory", category, nameMapper);
            Assert.AreNotEqual(0, result.AsInt());
        }
예제 #4
0
        public void FluentByNameMapper_Save() {
            INameMapper nameMapper = new CapitalizeNameMapper();

            var category = new Category
                           {
                               CategoryName = "Test",
                               Description = "FluentUtil"
                           };

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

            // insert
            var result = NorthwindAdoRepository.ExecuteEntity("SaveOrUpdateCategory", category, nameMapper);

            category.CategoryId = result.AsInt(-1);
            Assert.AreNotEqual(-1, category.CategoryId);

            // update
            result = NorthwindAdoRepository.ExecuteEntity("SaveOrUpdateCategory", category, nameMapper);
            Assert.IsTrue(result.AsInt() > 0);
        }
예제 #5
0
        public void FluentByNameMapper_Load() {
            INameMapper nameMapper = new CapitalizeNameMapper();

            using(var cmd = AdoRepository.GetCommand("CustOrderHist2")) {
                var orderHistories = AdoRepository.ExecuteInstance<CustomerOrderHistory>(nameMapper, cmd, CustomerTestParameter);

                orderHistories.Count.Should().Be.GreaterThan(0);
                CollectionAssert.AllItemsAreNotNull((ICollection)orderHistories);
                CollectionAssert.AllItemsAreInstancesOfType((ICollection)orderHistories, typeof(CustomerOrderHistory));
            }
        }
예제 #6
0
        public void MapFromDataReader_Employee_With_DynamicProxy() {
            var capitalizeNameMapper = new CapitalizeNameMapper();
            using(var reader = NorthwindAdoRepository.ExecuteReaderBySqlString(SQL_EMPLOYEE_SELECT)) {
                var employees = reader.Map<Employee>(DynamicProxyTool.CreateEditablePropertyChanged<Employee>, capitalizeNameMapper);
                Assert.Greater(employees.Count, 0);

                employees.All(emp => emp.EmployeeID > 0).Should().Be.True();
                employees.All(emp => emp.BirthDate.HasValue).Should().Be.True();

                // 모든 엔티티가 Proxy 된 것입니다!!!
                employees.All(emp => emp.IsDynamicProxy()).Should().Be.True();
            }
        }