-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Added extension methods for IDbTransaction #429
Conversation
While the commit is much appreciated - I'm not sure this is a common case, and it add's a lot of mostly-duplicate code to support such a case. To be honest: I'm not sure including this is worth the tradeoff in maintenance costs it introduces. |
No problem. I'm happy to close the request if you're sure you don't want to include. |
I don't think it's worth the cost, but I'm not so arrogant as to think I'm aware of all use cases and percentages in the world either :) Let's give it a chance and see if any others chime in with thoughts. |
This is actually something I thought about adding a while back; what held me back is - as you probably noticed - the annoying number of overloads you need to add to support this. If you are writing transaction based code, I totally get that this makes things more obvious and elegant than Given that the code exists, I'm not particularly against taking it. |
(note: I typo'd in my last comment, reversing the intent; my bad; tl;dr: I'm ok-ish with this) |
I would welcome this addition. I recently discovered dapper and really like it. So far I have been using it to extend a large existing system, which uses explicit transactions. I found that for calls with many parameters, it is easy to forget the transaction argument, since it comes after the arguments. |
Here's my fear: it doubles the surface area (and almost line count) for all future method additions as well. I'm don't think that is a good thing. What if we instead put this in Dapper.Transactions (an additional project/nuget) that contained and maintained all of these convenience overloads? I'm certainly not against having them, just the weight it adds to the core codebase is something we can't really go back on. Obviously this has the downside of "future methods may be forgotten" with respect to a transaction extension...but I think that's really true either way and not much less true in another file. It's also very easy to fix and deploy. |
I'd be good with the Dapper.Transactions (separate assembly) idea. If we
|
Okay I'll be honest, I don't know what I was smoking in the earlier comment. How bout we just put these in a We could also add a unit test that crawls for methods and checks if we're missing any (which can have exceptions where there shouldn't be a corresponding overload for some reason). |
Although, it occurs: this is already missing 50% of the overloads... |
Yeah...you just talked me out of supporting this. I'm not sure of a good middle-ground that doesn't involve that much duplication. |
Closing pull request. |
I've added extension methods for IDbTransaction, makes the syntax more fluent when dealing with transactions.