Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support named parameters everywhere you can pass parameters in, document this. #3604

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

elexisvenator
Copy link
Contributor

@elexisvenator elexisvenator commented Dec 20, 2024

Requires JasperFx/weasel#159 + related package update. Tests will not pass unless the latest package is there.

Some places supported named parameters (like .Query()) but this was not consistent. This PR adds support for the remaining places that I could think of (MatchesSql, QueueSqlCommand), adds tests for these changes as well as the changes in Weasel. I have also updated the documentation to mention named parameters wherever parameters are already discussed.

The tl:dr of the functional changes:

  • Passing in a single parameter that is an anonymous object will be treated as a bucket of named parameters.
  • Passing in a single parameter that is a IDictionary<string, T>, where T is anything, will be treated as a dictionary of named parameters.
  • The exception is compiled queries, which will continue to throw if named parameters are passed in. This is existing behaviour.

This should not break the public API for anyone, as previously passing in a dictionary or an anonymous object would have resulted in Npgsql throwing an error.

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