Repository navigation
Add interpolated SQL queries with DTO and tuple results - #208
Open
jogibear9988 wants to merge 4 commits into
Open
jogibear9988 wants to merge 4 commits into
jogibear9988 wants to merge 4 commits into
Conversation
This was referenced Oct 14, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add interpolated SQL queries that quote identifiers using the current provider, parameterize ordinary values, and return fully materialized DTOs or mapper-produced results.
This implements the SQL interpolation proposal in #202 using
FormattableString. It supports both explicit identifier wrappers and:column/:tableformat specifiers; neither syntax requires a custom interpolated string handler.Public API
Extension methods in
DotNetProjects.Migrator.Framework:DTO and identifier-wrapper example
DTO results reuse the column mapping from #206: the result column
GenericDefinitionpopulatesDefinitionvia its attribute.Format-specifier example
Identifier strings use explicit markers. An ordinary interpolated string becomes a parameter, not raw SQL.
Tuple / custom mapper example
The mapper overload also supports constructor-based DTOs and has no
class, new()constraint. In a Classic migration useDatabase.Query(...); in a fluent migration useContext.Query(...)for an immediate read.Behavior and limits
Sql.Colquotes a column identifier atom;Sql.Tablequotes a table path, including schema qualification. For a trusted SQL alias uses.{Sql.Col("Id")}.Column = {null}does not becomeIS NULL.FormattableString. Converting it tostringloses arguments; there is deliberately nostringoverload.FormattableStringalready supports both proposed syntaxes without that additional complexity.Part 2 of the implementation for #202. Depends on #206; merge #206 first, then retarget this PR to master. This targets
codex/dto-select-predicates, keeping the diff limited to interpolation and shared DTO materialization.Validation: