Skip to content

Commit e40f433

Browse files
committed
Grouped Save() parameters
In practice, the parameters can be set in any order—they needn't map to the order used in the stored procedure(s). This allows us to use more natural grouping. For instance, instead of checking `isNew` twice, we can just place both `CreateTopic` parameters within a single `isNew` condition. Also moved `@Attributes` to the end since doesn't use the `AddParameter()` overload and, thus, doesn't align nicely with the other parameters.
1 parent 9f0fdbc commit e40f433

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

OnTopic.Data.Sql/SqlTopicRepository.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,14 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false, bool is
341341
\-----------------------------------------------------------------------------------------------------------------------*/
342342
if (!isNew) {
343343
command.AddParameter("TopicID", topic.Id);
344+
command.AddParameter("DeleteRelationships", true);
344345
}
345346
else if (topic.Parent != null) {
346347
command.AddParameter("ParentID", topic.Parent.Id);
347348
}
348-
command.Parameters.AddWithValue("@Attributes", attributes);
349-
if (!isNew) {
350-
command.AddParameter("DeleteRelationships", true);
351-
}
352349
command.AddParameter("Version", version.Value);
353350
command.AddParameter("ExtendedAttributes", extendedAttributes);
351+
command.Parameters.AddWithValue("@Attributes", attributes);
354352
command.AddOutputParameter();
355353

356354
/*------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)