Created
July 30, 2020 07:41
-
-
Save cezarypiatekGC/f7b863832fa78bc15546479a3cd4e71f to your computer and use it in GitHub Desktop.
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
public static class PatchExtensions | |
{ | |
public static bool HasBeenChanged<T, TProperty>(this JsonPatchDocument<T> patch, Expression<Func<T, TProperty>> field) where T : class | |
{ | |
var fieldPathWithPrefix = field.Body.ToString().Replace(".", "/"); | |
var fieldPath = fieldPathWithPrefix.Substring(fieldPathWithPrefix.IndexOf("/", StringComparison.InvariantCulture)); | |
return patch.Operations.Any(x => x.path == fieldPath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment