Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply JsonPatch when set of properties are different in DTO than Entity #2422

Closed
aspnet-hello opened this issue Jan 1, 2018 · 3 comments
Closed
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question

Comments

@aspnet-hello
Copy link

From @sachinpachori on Wednesday, December 27, 2017 3:19:02 PM

This is a common scenario where your DTO/viewmodel could be different from the Entities. In this case how to use this JSONPatch with ApplyTo function. If possible, I think you should work on providing this feature.

Copied from original issue: aspnet/JsonPatch#127

@mkArtakMSFT
Copy link
Member

This is not a functionality we provide explicitly, but you can use something like AutoMapper(http://automapper.org/) to handle it.

@Eilon Eilon added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed repo:JsonPatch labels Nov 7, 2018
natemcmaster pushed a commit that referenced this issue Nov 14, 2018
@RoboBurned
Copy link

It is almost useless without this feature.
void Patch(JsonPatchDocument patch)
{
patch.ApplyTo(userEntity);
}
I cannot use it this way because my UserEntity has collection of Roles and anybody can "patch" it.
We need to separate the list of fields in patch from the entity.

@migpfernandes
Copy link

Hi,
is there any new solution to perform this kind of actions? I've two scenarios for this where I'm getting stuck:

  1. I have a gateway that first receives the PatchDocument and then propagates request for proper service through it's SDK. Gateway type is JsonPatchDocument<Gateway.ContactDTO> and service is JsonPatchDocument<Service.ContactDTO>. Any elegant way of converting one to another?
  2. In service we want to receive the JsonPatchDocument<Service.ContactDTO> but apply it to Service.Domain.Contact. Is this possible without getting domain object, mapping to DTO, applying Patch and converting to Domain object again?

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question
Projects
None yet
Development

No branches or pull requests

5 participants