Skip to content

How to handle the errors message RMG007 and CS8795 in Mapperly. And reduce to code #581

Closed Answered by TimothyMakkison
qwertybba asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, thanks for using Mapperly.

It would help if you shared User, UsersToRoleDto and Role etc but I came up with the following.

Mapperly can't know that you want path User.FullName of type User to map to path User of type string. the paths dont match. Instead it tries to map both User members together. This fails because it doesn't know how to convert from User -> string. I suggest you use MapProperty docs or define how to convert from string -> User and User -> string

[Mapper]
public partial class Mapper
{
    [MapProperty("User.FullName", "User")]
    [MapProperty("Role.Name", "Role")]
    public partial UsersToRoleDto Map(UsersToRole usersToRole);

    [MapProperty("User", "User.FullName"

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@qwertybba
Comment options

@TimothyMakkison
Comment options

@qwertybba
Comment options

@qwertybba
Comment options

@TimothyMakkison
Comment options

Answer selected by qwertybba
Comment options

You must be logged in to vote
1 reply
@TimothyMakkison
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants