public Task <GetInvoicesDbQueryResult> HandleAsync(GetInvoicesDbQuery query, CancellationToken cancellationToken) { Assert.IsNotNull(query); var request = ToExecuteReaderRequest(query, cancellationToken); return(ExecuteReaderAsync(request)); }
public GetInvoicesDbQueryResult Handle(GetInvoicesDbQuery query) { Assert.IsNotNull(query); var request = ToExecuteReaderRequest(query, CancellationToken.None); return(ExecuteReader(request)); }
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); } }
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); } }
private ExecuteReaderRequest ToExecuteReaderRequest(GetInvoicesDbQuery query, CancellationToken cancellationToken) { var createCommandRequest = ToCreateCommandRequest(query); return(new ExecuteReaderRequest(createCommandRequest, CommandBehavior.Default, cancellationToken)); }
private static ReadOnlyCollection <object> ToParameters(GetInvoicesDbQuery query) { var parameters = new SqlParameterCollectionBuilder(); return(parameters.ToReadOnlyCollection()); }
private CreateCommandRequest ToCreateCommandRequest(GetInvoicesDbQuery query) { var parameters = ToParameters(query); return(new CreateCommandRequest(CommandText, parameters, CommandType.Text, CommandTimeout, _transaction)); }