public async Task <TimeoutData> Peek(string timeoutId, ContextBag context) { var guid = sqlDialect.ConvertTimeoutId(timeoutId); using (var connection = await connectionManager.OpenNonContextualConnection().ConfigureAwait(false)) using (var command = connection.CreateCommand()) { command.CommandText = timeoutCommands.Peek; command.AddParameter("Id", guid); // to avoid loading into memory SequentialAccess is required which means each fields needs to be accessed using (var reader = await command.ExecuteReaderAsync(CommandBehavior.SingleRow | CommandBehavior.SequentialAccess).ConfigureAwait(false)) { if (!await reader.ReadAsync().ConfigureAwait(false)) { return(null); } var destination = await reader.GetFieldValueAsync <string>(0).ConfigureAwait(false); var sagaId = await reader.GetGuidAsync(1).ConfigureAwait(false); var value = await reader.GetFieldValueAsync <byte[]>(2).ConfigureAwait(false); var dateTime = await reader.GetFieldValueAsync <DateTime>(3).ConfigureAwait(false); var headers = ReadHeaders(reader); return(new TimeoutData { Id = timeoutId, Destination = destination, SagaId = sagaId, State = value, Time = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc), Headers = headers, }); } } }