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()); } } }
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); } }
public void ExecuteReaderToInstanceByNameMapping() { using (var cmd = NorthwindAdoRepository.GetCommand(GetCustomerOrderHistorySql)) { var orderHistories = NorthwindAdoRepository.ExecuteInstance <CustomerOrderHistory>(NameMappings, cmd, CustomerTestParameter); if (IsDebugEnabled) { log.Debug(orderHistories.CollectionToString()); } } }