Path: redb-route/redb.Route.Sql/Batch/BatchRowCollector.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Sql/Batch/BatchRowCollector.cs ---- using System.Collections; using System.Data.Common; using redb.Route.Sql.Mapping; namespace redb.Route.Sql.Batch; /// /// Collects the rows a batch's statements return (INSERT … RETURNING, OUTPUT inserted.*) in item order, for /// . Rows are Dictionary<string, object?>, or the outputClass type. /// internal sealed class BatchRowCollector { private readonly Func _map; private BatchRowCollector(IList rows, Func map) { Rows = rows; _map = map; } /// The rows collected so far: a List<T> of the row type. internal IList Rows { get; } /// Number of rows collected so far. internal int Count => Rows.Count; /// /// A collector when ask for rows — an outputType other than None, with /// Auto decided by — or null, when the batch reads no rows. Rows map to /// , the endpoint's outputClass mapping, or to dictionaries without one. /// internal static BatchRowCollector? Create(SqlEndpointOptions options, SqlRowMapperFactory.PocoMapping? poco, string sql) { // Under Auto a batch reads no rows, as Apache Camel's executeBatch collects no result sets: the keys of a batch are // asked for with an explicit outputType. The text is never parsed for it. if (options.OutputType is SqlOutputType.None or SqlOutputType.Auto) return null; if (poco is not null) return new BatchRowCollector(poco.CreateList(), poco.Map); var mapper = new DictionaryRowMapper(); return new BatchRowCollector(new List>(), reader => mapper.Map(reader)); } /// Reads every row of every result set of , in order. internal async Task ReadAllAsync(DbDataReader reader, CancellationToken ct) { do { while (await reader.ReadAsync(ct).ConfigureAwait(false)) Rows.Add(_map(reader)); } while (await reader.NextResultAsync(ct).ConfigureAwait(false)); } /// Drops the rows collected after the first : those of an item undone to its savepoint. internal void Truncate(int count) { while (Rows.Count > count) Rows.RemoveAt(Rows.Count - 1); } }