|
5 | 5 | \=============================================================================================================================*/ |
6 | 6 | using System; |
7 | 7 | using System.Data; |
8 | | -using System.Diagnostics; |
9 | 8 | using System.Diagnostics.CodeAnalysis; |
10 | 9 | using System.Globalization; |
11 | 10 | using System.Linq; |
@@ -389,9 +388,9 @@ public override int Save([NotNull]Topic topic, bool isRecursive = false, bool is |
389 | 388 | | Close connection |
390 | 389 | \-----------------------------------------------------------------------------------------------------------------------*/ |
391 | 390 | finally { |
392 | | - if (command != null) command.Dispose(); |
393 | | - if (connection != null) connection.Dispose(); |
394 | | - if (attributes != null) attributes.Dispose(); |
| 391 | + command?.Dispose(); |
| 392 | + connection?.Dispose(); |
| 393 | + attributes.Dispose(); |
395 | 394 | } |
396 | 395 |
|
397 | 396 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -473,8 +472,8 @@ public override void Move(Topic topic, Topic target, Topic? sibling) { |
473 | 472 | | Close connection |
474 | 473 | \-----------------------------------------------------------------------------------------------------------------------*/ |
475 | 474 | finally { |
476 | | - if (command != null) command.Dispose(); |
477 | | - if (connection != null) connection.Dispose(); |
| 475 | + command?.Dispose(); |
| 476 | + connection.Dispose(); |
478 | 477 | } |
479 | 478 |
|
480 | 479 | /*------------------------------------------------------------------------------------------------------------------------ |
@@ -532,8 +531,8 @@ public override void Delete(Topic topic, bool isRecursive = false) { |
532 | 531 | | Close connection |
533 | 532 | \-----------------------------------------------------------------------------------------------------------------------*/ |
534 | 533 | finally { |
535 | | - if (command != null) command.Dispose(); |
536 | | - if (connection != null) connection.Dispose(); |
| 534 | + command?.Dispose(); |
| 535 | + connection?.Dispose(); |
537 | 536 | } |
538 | 537 |
|
539 | 538 | } |
@@ -615,8 +614,8 @@ private static string PersistRelations(Topic topic, SqlConnection connection, bo |
615 | 614 | | Close connection |
616 | 615 | \-----------------------------------------------------------------------------------------------------------------------*/ |
617 | 616 | finally { |
618 | | - if (command != null) command.Dispose(); |
619 | | - if (targetIds != null) targetIds.Dispose(); |
| 617 | + command?.Dispose(); |
| 618 | + targetIds.Dispose(); |
620 | 619 | //Since the SQL connection is being passed in, do not close connection; this allows command pooling. |
621 | 620 | //if (connection != null) connection.Dispose(); |
622 | 621 | } |
|
0 commit comments