public GetCustomerInvoicesDbQueryResult Handle(GetCustomerInvoicesDbQuery query)
        {
            Assert.IsNotNull(query);
            var request = ToExecuteReaderRequest(query, CancellationToken.None);

            return(ExecuteReader(request));
        }
        public Task <GetCustomerInvoicesDbQueryResult> HandleAsync(GetCustomerInvoicesDbQuery query, CancellationToken cancellationToken)
        {
            Assert.IsNotNull(query);
            var request = ToExecuteReaderRequest(query, cancellationToken);

            return(ExecuteReaderAsync(request));
        }
        private static ReadOnlyCollection <object> ToParameters(GetCustomerInvoicesDbQuery query)
        {
            var parameters = new SqlParameterCollectionBuilder();

            parameters.Add("customerId", query.CustomerId);
            parameters.AddDate("invoiceDate", query.InvoiceDate);
            return(parameters.ToReadOnlyCollection());
        }
Esempio n. 4
0
 public void TestMethod1()
 {
     using (var sqlConnection = SqlConnectionFactory.CreateSqlConnection())
     {
         sqlConnection.Open();
         var query        = new GetCustomerInvoicesDbQuery(customerId: 1, invoiceDate: DateTime.Today);
         var queryHandler = new GetCustomerInvoicesDbQueryHandler(sqlConnection, transaction: null);
         var queryResult  = queryHandler.Handle(query);
     }
 }
        private ExecuteReaderRequest ToExecuteReaderRequest(GetCustomerInvoicesDbQuery query, CancellationToken cancellationToken)
        {
            var createCommandRequest = ToCreateCommandRequest(query);

            return(new ExecuteReaderRequest(createCommandRequest, CommandBehavior.Default, cancellationToken));
        }
        private CreateCommandRequest ToCreateCommandRequest(GetCustomerInvoicesDbQuery query)
        {
            var parameters = ToParameters(query);

            return(new CreateCommandRequest(CommandText, parameters, CommandType.Text, CommandTimeout, _transaction));
        }