예제 #1
0
        public void ExecuteReaderToInstanceByConverter()
        {
            Func <IDataReader, CustomerOrderHistory> @mapFunc
                = delegate(IDataReader dr) {
                var reader = dr;
                return(new CustomerOrderHistory
                {
                    ProductName = reader.AsString("ProductName"),
                    Total = reader.AsInt32Nullable("Total")
                });
                };

            using (var cmd = NorthwindAdoRepository.GetCommand(GetCustomerOrderHistorySql)) {
                var orderHistories = NorthwindAdoRepository.ExecuteInstance(@mapFunc, cmd, CustomerTestParameter);

                if (IsDebugEnabled)
                {
                    log.Debug(orderHistories.CollectionToString());
                }
            }

            Func <IDataReader, CustomerOrderHistory> mapFunc2 = DataReaderToCustomerOrderHistory;

            using (var cmd = NorthwindAdoRepository.GetCommand(GetCustomerOrderHistorySql)) {
                var orderHistories = NorthwindAdoRepository.ExecuteInstance(mapFunc2, cmd, CustomerTestParameter);

                if (IsDebugEnabled)
                {
                    log.Debug(orderHistories.CollectionToString());
                }
            }
        }
예제 #2
0
        public void ExecuteReaderWithPagingByNameMapper(int pageIndex, int pageSize)
        {
            using (var cmd = NorthwindAdoRepository.GetCommand(SQL_ORDER_DETAIL_SELECT)) {
                var orderDetails = NorthwindAdoRepository.ExecuteInstance <OrderDetail>(TrimMapper, cmd, pageIndex, pageSize);

                Console.WriteLine(orderDetails);
            }
        }
예제 #3
0
        public void ExecuteReaderToInstanceByNameMapping()
        {
            using (var cmd = NorthwindAdoRepository.GetCommand(GetCustomerOrderHistorySql)) {
                var orderHistories = NorthwindAdoRepository.ExecuteInstance <CustomerOrderHistory>(NameMappings, cmd,
                                                                                                   CustomerTestParameter);

                if (IsDebugEnabled)
                {
                    log.Debug(orderHistories.CollectionToString());
                }
            }
        }