Skip to content

Generator: serve Map<T>() on the DbQuery types too - #280

Merged
electricessence merged 1 commit into
masterfrom
fix/dbquery-generated-map
Dec 1, 2026
Merged

electricessence merged 1 commit into
masterfrom
fix/dbquery-generated-map

Conversation

@electricessence

Copy link
Copy Markdown
Collaborator

A plain Map<T>() on a DbQuery, a DbQuery<TParams>, a DbQueryUsing or a DbQueryCall now reads rows with a generated row reader, as it does on a command or a reader. These types declare Map<T>() themselves, and the generator only looked at the extension methods, so every query defined this way used the runtime map. No Core code changes.

  • Each interceptor calls the same type's existing Map(RowMap<T>?) with the model's generated map. The readonly structs are taken by in; the typed definition gets a generic interceptor that never names TParams, so a private parameter type or a type parameter of the caller works.
  • Behavior change: these calls no longer get the runtime map's conversions (see the generator's "Known differences"). <OdxGenerateMaps>false</OdxGenerateMaps> switches generation off, as before.
  • Generated output for a project with no such call is unchanged: the generator tests' output is byte-identical before and after on the unchanged test sources.
  • Tests compare each new receiver with its own runtime map and check that generated code served it, including from values, variables and an in parameter, with a private parameter type, inside a generic method, a default struct, and a single value (not intercepted). The package consumer tests use all four with the generator on, off and with C# 12.
  • Docs: the statements that a DbQuery is not generated are updated, x?.Map<T>() is listed as not intercepted, and the release notes record the change.

🤖 Generated with Claude Code

A plain `Map<T>()` on a `DbQuery`, a `DbQuery<TParams>`, a `DbQueryUsing` or a `DbQueryCall` now reads rows with a generated row reader, as it does on a command or a reader. These types declare `Map<T>()` themselves, and the generator only looked at the extension methods, so every query defined this way used the runtime map. No Core code changes.

- Each interceptor calls the same type's existing `Map(RowMap<T>?)` with the model's generated map. The readonly structs are taken by `in`; the typed definition gets a generic interceptor that never names `TParams`, so a private parameter type or a type parameter of the caller works.
- **Behavior change:** these calls no longer get the runtime map's conversions (see the generator's "Known differences"). `<OdxGenerateMaps>false</OdxGenerateMaps>` switches generation off, as before.
- Generated output for a project with no such call is unchanged: the generator tests' output is byte-identical before and after on the unchanged test sources.
- Tests compare each new receiver with its own runtime map and check that generated code served it, including from values, variables and an `in` parameter, with a private parameter type, inside a generic method, a default struct, and a single value (not intercepted). The package consumer tests use all four with the generator on, off and with C# 12.
- Docs: the statements that a `DbQuery` is not generated are updated, `x?.Map<T>()` is listed as not intercepted, and the release notes record the change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 3fefe0a into master Dec 1, 2026
9 checks passed
@electricessence
electricessence deleted the fix/dbquery-generated-map branch December 1, 2026 19:57
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