Feature/rm 9639 batched save command factory#1404
Open
Conversation
…xecute and the according Test
refactored MultiDataContainerSaveCommand so it does not longer use Tuple<ObjectID,IDBCommandBuilder> but insted uses the new MultiDataContainerSaveCommandContext
a-ctor
requested changes
Feb 24, 2026
Comment on lines
+72
to
+91
| private IEnumerable<SingleObjectMultiDataContainerSaveCommandContext> CreateDbCommandsForSave (IEnumerable<DataContainer> dataContainers) | ||
| { | ||
| var insertCommands = new List<Tuple<ObjectID, IDbCommandBuilder>>(); | ||
| var updateCommands = new List<Tuple<ObjectID, IDbCommandBuilder>>(); | ||
| var deleteCommands = new List<Tuple<ObjectID, IDbCommandBuilder>>(); | ||
| var insertCommands = new List<SingleObjectMultiDataContainerSaveCommandContext>(); | ||
| var updateCommands = new List<SingleObjectMultiDataContainerSaveCommandContext>(); | ||
| var deleteCommands = new List<SingleObjectMultiDataContainerSaveCommandContext>(); | ||
|
|
||
| foreach (var dataContainer in dataContainers) | ||
| { | ||
| var tableDefinition = _tableDefinitionFinder.GetTableDefinition(dataContainer.ID); | ||
|
|
||
| if (ShouldCreateInsertCommand(dataContainer)) | ||
| insertCommands.Add(Tuple.Create(dataContainer.ID, CreateDbCommandForInsert(dataContainer, tableDefinition))); | ||
| insertCommands.Add(new SingleObjectMultiDataContainerSaveCommandContext(dataContainer.ID, CreateDbCommandForInsert(dataContainer, tableDefinition))); | ||
| if (ShouldCreateDeleteCommand(dataContainer)) | ||
| deleteCommands.Add(Tuple.Create(dataContainer.ID, CreateDbCommandForDelete(dataContainer, tableDefinition))); | ||
| deleteCommands.Add(new SingleObjectMultiDataContainerSaveCommandContext(dataContainer.ID, CreateDbCommandForDelete(dataContainer, tableDefinition))); | ||
|
|
||
| var updatedColumnValues = GetUpdatedColumnValues(dataContainer, tableDefinition).ToArray(); | ||
| if (updatedColumnValues.Any()) | ||
| { | ||
| var dbCommandForUpdate = CreateDbCommandForUpdate(dataContainer, tableDefinition, updatedColumnValues); | ||
| updateCommands.Add(Tuple.Create(dataContainer.ID, dbCommandForUpdate)); | ||
| updateCommands.Add(new SingleObjectMultiDataContainerSaveCommandContext(dataContainer.ID, dbCommandForUpdate)); |
Contributor
There was a problem hiding this comment.
I would prefer copying the MultiDataContainerSaveCommand and keeping this code as is. By keeping the new code separate we ensure that the working, battle tested, code is not lost and if a project falls back to the individual strategy it works like it does today. This also gives us a bit more freedom for refactoring the command once we implemented batching (because then we don't need the command context abstraction anymore).
What do you think?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://jira.rubicon.eu/browse/RM-9639