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.
Observations
A DbBatch looks like a DbCommand, but just on the surface.
Unlike batching which uses an underlying
DbCommand
,DbBatch
will require special handling for things such asPrepare
,Enlist
etc. While theDbBatch
could theoretically be wrapped in aDbCommand
"adapter" or even a NH specific "DbCommandOrBatch
", sinceDbBatch
is now a part of the core .NET 6+ API, I think the route forward is to be explicit about it, e.g. having bothEnlist(DbCommand)
andEnlist(DbBatch)
.This means that a transparent move is harder, since custom derivatives of e.g MicrosoftDataSqlClientDriver may have vital implementations of e.g
AdjustCommand
that will have to be duplicated forDbBatch
.No really good way to create a DbBatchCommand from a DbCommand
If I'm not missing something, I think this is a bit of an oversight on the part of the
DbBatch
creators, especially since they already use "CanDoXxxx
" properties.All the parameters in a
DbCommand
will have to be recreated for theDbBatchCommand
, since they can't be attached to twoDbParameterCollections
at the same time. The good ol'SqlCommandSet
uses a bit of trickery for that, but I just opted to make sure that theDbParameter
isICloneable
, and used that. Perhaps the value should be explicitly cloned too, if it'sICloneable
. Making it possible to override this logic is probably a good idea.ReflectionBasedDriver doesn't use DbProviderFactoryDriveConnectionCommandProvider on .NET 5 and above
Any reason for this, or just an effect of NETSTANDARD2_1_OR_GREATER not including NET5 etc.?