You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am porting some manual mapping code to use mapperly as it is the first mapper I actually like. I use immutable positional records as DTOs. A good deal of my DTOs have a CanEdit property (some have more of these). The UI uses these to know if it should display edit button and so on. If the user can edit is determined by complex logic so I compute it in advance and then do the mapping with methods like this
public static DeviceDto ToDto(this Device device, bool canEdit)
{
return new DeviceDto(
device.DeviceId,
device.Name,
//... a bunch of trivial properties
device.DateCreated,
canEdit);
}
As you can see the last property (which is named CanEdit) comes from the mapping method parameter. My problem is that I can't have Mapperly handle this for me.
Describe the solution you'd like
I propose that Mapperly supports adding method parameters to the set of properties to map and mapping them by convention
Describe alternatives you've considered
I can think of several ways to work around this with an additional method but that would require adding a setter or creating a new record with "with" which means allocation and in any case that would add code that in theory can be handled by convention by the mapper
Do you think this would be a reasonable feature that is worth implementing?
P.S. Thanks for the great library, I particularly like how it tends to write the mappings very close to the style that I arrived at myself doing manual mapping.
The text was updated successfully, but these errors were encountered:
I am porting some manual mapping code to use mapperly as it is the first mapper I actually like. I use immutable positional records as DTOs. A good deal of my DTOs have a CanEdit property (some have more of these). The UI uses these to know if it should display edit button and so on. If the user can edit is determined by complex logic so I compute it in advance and then do the mapping with methods like this
As you can see the last property (which is named CanEdit) comes from the mapping method parameter. My problem is that I can't have Mapperly handle this for me.
Describe the solution you'd like
I propose that Mapperly supports adding method parameters to the set of properties to map and mapping them by convention
Describe alternatives you've considered
I can think of several ways to work around this with an additional method but that would require adding a setter or creating a new record with "with" which means allocation and in any case that would add code that in theory can be handled by convention by the mapper
Do you think this would be a reasonable feature that is worth implementing?
P.S. Thanks for the great library, I particularly like how it tends to write the mappings very close to the style that I arrived at myself doing manual mapping.
The text was updated successfully, but these errors were encountered: