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

Custom CreateCommand method. Resolves #2127 #2128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

billrob
Copy link
Contributor

@billrob billrob commented Oct 31, 2024

This allows the user to provide their own IDbCommand to be used by Dapper internally.

This allows the user to provide their own IDbCommand to be used by Dapper internally.
@billrob
Copy link
Contributor Author

billrob commented Nov 3, 2024

@mgravell Can I get some movement on this one?

@RyanThomas73
Copy link

@mgravell Can you give any status updates regarding acceptance/support for this?

@mgravell
Copy link
Member

Honestly, I'm just not sure it is a good fit, and it makes a lot of other things potentially much harder. If you're creating your own command: you probably don't need Dapper in the first place - or rather: it isn't going to do a lot for you. If what you want is to run the query API: the row materializer is already available via SqlMapper.GetTypeDeserializer. In particular, I'm concerned that baking this into the definition removes flexibility.

What is the actual core need here, that makes you want to pass in a command rather than either just use Dapper or just run your own command?

@billrob
Copy link
Contributor Author

billrob commented Dec 19, 2024

@mgravell He was trying to hook into the retry logic the sqlCommand ef core has baked in.

@billrob
Copy link
Contributor Author

billrob commented Dec 19, 2024

I actually agreed with him as I could see other use cases where you might want to have more control over the SqlCommand object. eg, working with Transactions or one time I sent the @loggedInUserId to each query so I could record all queries and who made them.

The risk looked low as the library sets the CommandType and CommandText. So if someone set their own and it was overridden that is acceptable behavior. IMO

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.

3 participants