Skip to content

Conversation

mgravell
Copy link
Member

@mgravell mgravell commented Mar 26, 2025

This adds a performance focused mode that switches from using flexible "we'll example the schema and bind whatever we see" to much stricter rules:

  • when [QueryColumns] is used, the column count should be >= the declared count
  • unwanted columns can be skipped by passing null/""
  • any remaining non-trivial columns must resolve to a member
  • the members are processed using pure ordinal logic, without looking at the column names

and

  • when [StrictTypes] is used, the members are processed using exact type logic, without looking at the data types

These can be combined to get a very simplified reader

We may later auto-enable this (or at least infer the columns) when possible, for example known TSQL using ScriptDom

Typical output; note Tokenize is trivial, and Read uses simple for loop without lookup via tokens:

image

@mgravell mgravell requested a review from DeagleGross March 26, 2025 17:14
…into strict-bind

# Conflicts:
#	test/Dapper.AOT.Test/Interceptors/QueryStrictBind.output.netfx.cs
#	test/Dapper.AOT.Test/Interceptors/QueryStrictBind.output.netfx.txt
@mgravell mgravell changed the title add [StrictBind(...)] add [QueryColumns] and [StrictTypes] Mar 27, 2025
@mgravell mgravell merged commit 693b0aa into main Mar 27, 2025
2 checks passed
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