{"id":20411847,"url":"https://github.com/markopapic/partialupdater","last_synced_at":"2025-07-10T01:35:46.532Z","repository":{"id":143393607,"uuid":"108459336","full_name":"MarkoPapic/PartialUpdater","owner":"MarkoPapic","description":"Partial Updater is a library for .NET developers that enables patching entities by providing the minimal JSON payload, containing only the fields that need to be updated, thus reducing the network traffic.","archived":false,"fork":false,"pushed_at":"2019-03-11T17:02:08.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-15T13:15:25.466Z","etag":null,"topics":["asp-net-core","json-payload","patching"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarkoPapic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-26T19:58:50.000Z","updated_at":"2022-04-11T10:15:52.000Z","dependencies_parsed_at":"2024-01-31T23:15:21.466Z","dependency_job_id":null,"html_url":"https://github.com/MarkoPapic/PartialUpdater","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkoPapic%2FPartialUpdater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkoPapic%2FPartialUpdater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkoPapic%2FPartialUpdater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkoPapic%2FPartialUpdater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarkoPapic","download_url":"https://codeload.github.com/MarkoPapic/PartialUpdater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241955565,"owners_count":20048498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","json-payload","patching"],"created_at":"2024-11-15T05:54:12.251Z","updated_at":"2025-03-05T03:19:07.833Z","avatar_url":"https://github.com/MarkoPapic.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Partial Updater\n\n[![Build Status](https://travis-ci.org/MarkoPapic/PartialUpdater.svg?branch=develop)](https://travis-ci.org/MarkoPapic/PartialUpdater)\n\nPartial Updater is a library for .NET developers that enables patching entities by providing the minimal JSON payload, containing only the fields that need to be updated, thus reducing the network traffic. It converts JSON payload to an expression tree, which is then used to create update function.\n\n## Installation\n[![NuGet Version](https://img.shields.io/nuget/vpre/PartialUpdater.svg)](https://www.nuget.org/packages/PartialUpdater)\n```\nInstall-Package PartialUpdater -Version 1.0.0-beta\n```\n\n## Usage\nSay you have some blog post entity\n```cs\nclass Post\n{\n\tpublic int Id { get; set; }\n\tpublic string Title { get; set; }\n\tpublic DateTime Published { get; set; }\n\tpublic DateTime LastUpdated { get; set; }\n\tpublic string Content { get; set; }\n\tpublic Author Author { get; set; }\n}\n```\nthat needs to be updated over network. `Post`'s `Author` property is of type `Author`\n```cs\nclass Author\n{\n\tpublic string Username { get; set; }\n\tpublic string FirstName { get; set; }\n\tpublic string LastName { get; set; }\n\tpublic ContactInfo ContactInfo { get; set; }\n}\n```\nwhich, among others, has a `ContactInfo` property of type `ContactInfo`\n```cs\nclass ContactInfo\n{\n\tpublic string Email { get; set; }\n\tpublic string Website { get; set; }\n}\n```\nNow imagine a user edits the post title and author's email in the browser (or some other remote app) and wants to save it. They could send the JSON representation of the updated post over network and then you would replace the original post with the updated one. That way, they could end up sending a large amount of unnecessary data over network (including post content which can be large) along with the post title and author's email that need to be updated. With Partial Updater, a client can send JSON that only contains the fields that need to be updated:\n```json\n{\n\t\"author\": {\n\t\t\"contactInfo\": {\n\t\t\t\"email\": \"newemail@example.com\"\n\t\t}\n\t},\n\t\"title\": \"New title\"\n}\n```\nand you can update the original entity the following way:\n```cs\nPartialUpdate partialUpdate = JsonConvert.DeserializeObject\u003cPartialUpdate\u003cPost\u003e\u003e(jsonString);\npartialUpdate.Apply(originalPost);\n```\nwhere `jsonString` is a variable of type `string` that contains the above JSON content and `originalPost` is an object of type `Post` that represents the original blog post entity that will be updated.\n`Apply` method will only update the fields specified in the JSON payload (even if they are nested) and all the other fields in the original post will remain unchanged.\n\n### Using with ASP.NET Core\nImagine your blog from the previous example is an ASP.NET Core MVC application. In that case, all you need to do is to accept `PartialUpdate\u003cT\u003e` type from the request body and pass your entity type as a generic parameter.\n```cs\npublic class BlogController : Controller\n{\n\t[HttpPatch]\n\tpublic void UpdatePost([FromBody] PartialUpdate\u003cPost\u003e partialUpdate)\n\t{\n\t\tPost originalPost = ... //retrieve the original post\n\t\tpartialUpdate.Apply(originalPost);\n\t\t//save the post\n\t}\n}\n```\n\n## Building from source\n```\ngit clone https://github.com/MarkoPapic/PartialUpdater.git\ncd PartialUpdater\ndotnet restore\ndotnet build ./PartialUpdater.sln\ndotnet test ./PartialUpdater.Tests/\n```\n\n## License\n[MIT License](https://github.com/MarkoPapic/PartialUpdater/blob/master/LICENSE.txt)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkopapic%2Fpartialupdater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkopapic%2Fpartialupdater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkopapic%2Fpartialupdater/lists"}