コード例 #1
0
        public Task <GetInvoicesDbQueryResult> HandleAsync(GetInvoicesDbQuery query, CancellationToken cancellationToken)
        {
            Assert.IsNotNull(query);
            var request = ToExecuteReaderRequest(query, cancellationToken);

            return(ExecuteReaderAsync(request));
        }
コード例 #2
0
        public GetInvoicesDbQueryResult Handle(GetInvoicesDbQuery query)
        {
            Assert.IsNotNull(query);
            var request = ToExecuteReaderRequest(query, CancellationToken.None);

            return(ExecuteReader(request));
        }
コード例 #3
0
 public void TestMethod1()
 {
     using (var sqlConnection = SqlConnectionFactory.CreateSqlConnection())
     {
         sqlConnection.Open();
         var query        = new GetInvoicesDbQuery();
         var queryHandler = new GetInvoicesDbQueryHandler(sqlConnection, transaction: null);
         var queryResult  = queryHandler.Handle(query);
     }
 }
コード例 #4
0
        public async Task TestMethod2()
        {
            using (var sqlConnection = SqlConnectionFactory.CreateSqlConnection())
            {
                await sqlConnection.OpenAsync();

                var query        = new GetInvoicesDbQuery();
                var queryHandler = new GetInvoicesDbQueryHandler(sqlConnection, transaction: null);
                var queryResult  = await queryHandler.HandleAsync(query, CancellationToken.None);
            }
        }
コード例 #5
0
        private ExecuteReaderRequest ToExecuteReaderRequest(GetInvoicesDbQuery query, CancellationToken cancellationToken)
        {
            var createCommandRequest = ToCreateCommandRequest(query);

            return(new ExecuteReaderRequest(createCommandRequest, CommandBehavior.Default, cancellationToken));
        }
コード例 #6
0
        private static ReadOnlyCollection <object> ToParameters(GetInvoicesDbQuery query)
        {
            var parameters = new SqlParameterCollectionBuilder();

            return(parameters.ToReadOnlyCollection());
        }
コード例 #7
0
        private CreateCommandRequest ToCreateCommandRequest(GetInvoicesDbQuery query)
        {
            var parameters = ToParameters(query);

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