Created
September 2, 2017 18:24
-
-
Save winnicki/2392cb561ac5aa919bc27ce8ee652ae2 to your computer and use it in GitHub Desktop.
LINQ to JSON Upsert
This file contains 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 async Task SaveLocation(JObject locationJObject, int locationId) | |
{ | |
await Task.Run(() => | |
{ | |
var companyJObject = JObject.Parse(RawJson.Company); | |
companyJObject[nameof(Company.Locations)]? | |
.FirstOrDefault(x => (decimal)x[nameof(Location.Id)] == locationId) | |
.Replace(locationJObject); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment