From 9209bada7a958078471ff6f0f748edd16dc7a483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Ko=C5=BEelj?= Date: Tue, 24 Jan 2023 16:28:49 +0100 Subject: [PATCH] Fix cached command builder --- src/Connected.Data/Update/CommandBuilder.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Connected.Data/Update/CommandBuilder.cs b/src/Connected.Data/Update/CommandBuilder.cs index 0892801..69ce790 100644 --- a/src/Connected.Data/Update/CommandBuilder.cs +++ b/src/Connected.Data/Update/CommandBuilder.cs @@ -28,10 +28,12 @@ internal abstract class CommandBuilder if (TryGetExisting(out StorageOperation? existing)) { + if (existing is null) + return null; /* - * We need to rebuild an instance since StorageOperation - * is immutable - */ + * We need to rebuild an instance since StorageOperation + * is immutable + */ var result = new StorageOperation { CommandText = existing.CommandText, @@ -43,7 +45,7 @@ internal abstract class CommandBuilder if (result.Parameters is null) return result; - foreach (var parameter in result.Parameters) + foreach (var parameter in existing.Parameters) { if (parameter.Direction == ParameterDirection.Input) {