diff --git a/README.md b/README.md index 23c8818..91d34b1 100644 --- a/README.md +++ b/README.md @@ -2001,11 +2001,13 @@ var patch = new SomePatchRequestModel { } }; -// Deconstruct the patch field +// Extract operation per field var usernmae = patch.Username; -var operation = GetOperation(nameOf(patch.Username); +if (TryGetOperation(nameOf(patch.Username), out operation)) { + Console.WriteLine($"Operation: {operation}, Value: {value}"); +} + -Console.WriteLine($"Operation: {operation}, Value: {value}"); ``` --- diff --git a/src/MaksIT.Core/Abstractions/Webapi/PatchRequestModelBase.cs b/src/MaksIT.Core/Abstractions/Webapi/PatchRequestModelBase.cs index d3ded78..3813e04 100644 --- a/src/MaksIT.Core/Abstractions/Webapi/PatchRequestModelBase.cs +++ b/src/MaksIT.Core/Abstractions/Webapi/PatchRequestModelBase.cs @@ -15,8 +15,8 @@ public abstract class PatchRequestModelBase : RequestModelBase { .Where(prop => prop.Name != nameof(Operations)) .Any(prop => prop.GetValue(this) != null); - public PatchOperation GetOperation(string propertyName) { - return Operations[propertyName]; + public bool TryGetOperation(string propertyName, out PatchOperation operation) { + return Operations.TryGetValue(propertyName, out operation); } public override IEnumerable Validate(ValidationContext validationContext) { diff --git a/src/MaksIT.Core/MaksIT.Core.csproj b/src/MaksIT.Core/MaksIT.Core.csproj index d8e068c..4607f63 100644 --- a/src/MaksIT.Core/MaksIT.Core.csproj +++ b/src/MaksIT.Core/MaksIT.Core.csproj @@ -8,7 +8,7 @@ MaksIT.Core - 1.2.4 + 1.2.5 Maksym Sadovnychyy MAKS-IT MaksIT.Core