Path: redb-route/redb.Route.Sql/Mapping/DictionaryRowMapper.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/Mapping/DictionaryRowMapper.cs
----
using System.Data.Common;
namespace redb.Route.Sql.Mapping;
///
/// Maps a row to Dictionary<string, object?>.
/// Column names are keys, values are as-is from the provider (DBNull → null).
///
public sealed class DictionaryRowMapper : ISqlRowMapper>
{
///
public Dictionary Map(DbDataReader reader)
{
var fieldCount = reader.FieldCount;
var row = new Dictionary(fieldCount, StringComparer.OrdinalIgnoreCase);
for (var i = 0; i < fieldCount; i++)
{
var name = reader.GetName(i);
var value = reader.IsDBNull(i) ? null : reader.GetValue(i);
row[name] = value;
}
return row;
}
}