Skip to content

rc.4: table.Map<T>() maps the rows of a DataTable you already have (MappedTable<T>) - #120

Merged
electricessence merged 2 commits into
masterfrom
feat/datatable-map
Nov 11, 2026
Merged

electricessence merged 2 commits into
masterfrom
feat/datatable-map

Conversation

@electricessence

Copy link
Copy Markdown
Collaborator

table.Map<T>(): map the rows of a DataTable you already have, for 11.0.0-rc.4 (API shape).

using DataTable table = reader.ToDataTable();
List<Post> posts = table.Map<Post>().ToList();

What

  • table.Map<T>() returns MappedTable<T>, a readonly record struct that implements IMappedQuery<T> with the reader view's members (every terminal in sync and async form, Read/ReadAsync, Skip/Take). No SingleResult(), since a table has one result set.
  • The same 5 Map<T> overloads as on IDataReader and IDbCommand: the same parameter lists, OverloadResolutionPriority values and guards. A null map maps like Map<T>().
  • It is a shortcut for table.CreateDataReader().Map<T>(), which keeps working. The difference is ownership: the view creates and disposes its own reader.

Ownership

  • Each terminal reads the table's current rows through a new DataTableReader and disposes it. The table is not changed or cleared, so the view can be read more than once. No connection is involved, and NextResult is never called.
  • The asynchronous terminals complete synchronously, because the rows are in memory. A cancelled token gives a cancelled task.

Deprecations now point here

  • The messages for To<T>(DataTable, map, clearSourceTable), Transformer<T>.Results(DataTable, bool) and ResultsFromDataTable<T> name table.Map(map).ToList(). So do their rows in whats-new-11 and the ResultsFromDataTable "after" sample.

Docs and tests

  • mapping.md gets a short DataTable section with a compiled sample that the samples run checks. whats-new-11 lists the addition.
  • MappedTableTests covers:
    • parity with the reader view for every terminal (sync and async);
    • reading the same view twice, with the table unchanged;
    • a Read abandoned part way;
    • null and empty maps;
    • a single-value T;
    • an empty table;
    • Skip/Take;
    • cancellation;
    • a default struct;
    • null arguments.

Checks

  • Release and Debug builds: 0 warnings, 0 errors. Tests: 9677 of 9677 pass in both. Samples: 103 of 103 checks pass. Style and analyzers: 0 findings. DocFX: 0 warnings.

🤖 Generated with Claude Code

electricessence and others added 2 commits November 10, 2026 18:42
… the obsolete To<T>(DataTable)

The "after" sample (shown in whats-new-11) and the deprecation test now use the replacement the
ResultsFromDataTable message names: table.CreateDataReader(), then Map(map).ToList().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shortcut for table.CreateDataReader().Map<T>(): MappedTable<T> has the reader view's
members (no SingleResult) and the same five Map overloads. Each terminal reads the table
through its own DataTableReader and disposes it; the table is not changed, so the view
can be read more than once. The To<T>(DataTable), Transformer<T>.Results(DataTable) and
ResultsFromDataTable messages, the samples and whats-new now point at table.Map(map).ToList().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@electricessence
electricessence merged commit f39990b into master Nov 11, 2026
2 checks passed
@electricessence
electricessence deleted the feat/datatable-map branch November 11, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant