Last active
September 15, 2017 01:15
-
-
Save winnicki/b62cfe1623cf66d4e1bd8d28b4c35e51 to your computer and use it in GitHub Desktop.
A Simple LINQ to JSON Query
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 async Task<JObject> GetLocationJObject(int locationId) | |
{ | |
return await Task.Run(() => | |
{ | |
var companyJObject = JObject.Parse(RawJson.Company); // parsing to JObject is fast even for large objects | |
var locationJObject = companyJObject[nameof(Company.Locations)]? | |
.FirstOrDefault(x => (int)x[nameof(Location.Id)] == locationId) as JObject; | |
return locationJObject; | |
}) | |
.ConfigureAwait(false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment