public async Task <CommitsLoad> LoadCommitsAsync(string streamId) { Expect.NotDisposed(isDisposed); Expect.NotEmpty(streamId, "streamId"); var routingInfo = routing.CreateRoutingInfo(streamId); return(await Execute(async() => { var result = new List <Commit>(); var conn = await GetOrCreateOpenedConnection(routingInfo).ConfigureAwait(false); using (var cmd = SqlCommands.Load(streamId, routingInfo.Partition, schema)) { cmd.Connection = conn; using (var reader = await cmd.ExecuteReaderAsync().ConfigureAwait(false)) { while (reader.Read()) { var commit = ReadRowAsCommit(reader); result.Add(commit); } } } var commits = result.OrderBy(c => c.Version).ToArray(); return commits.Length > 0 ? new CommitsLoad(commits, commits.Last().Version) : CommitsLoad.Empty; }).ConfigureAwait(false)); }