How to handle the errors message RMG007 and CS8795 in Mapperly. And reduce to code #581
-
In my project I am trying to implement Mapperly so I do that
Now to the error messages if I remove the [Mapper] attribute then I get these error messages:
on this line of code
But if I added the [Mapper] attribute I get these error messages:
on this line of code |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hey, thanks for using Mapperly. It would help if you shared Mapperly can't know that you want path [Mapper]
public partial class Mapper
{
[MapProperty("User.FullName", "User")]
[MapProperty("Role.Name", "Role")]
public partial UsersToRoleDto Map(UsersToRole usersToRole);
[MapProperty("User", "User.FullName")]
[MapProperty("Role", "Role.Name")]
public partial UsersToRole Map(UsersToRoleDto usersToRoleDto);
}
Unfortunately Mapperly doesn't have a reverse map substitute 😐 |
Beta Was this translation helpful? Give feedback.
-
Hello Timothy Makkison,
But I get this error message
I get this error message:
Thank you for your time. Please accept my apologies. |
Beta Was this translation helpful? Give feedback.
-
I have marked Role and User as nullable but I am still getting the error.
On this line of code |
Beta Was this translation helpful? Give feedback.
Hey, thanks for using Mapperly.
It would help if you shared
User
,UsersToRoleDto
andRole
etc but I came up with the following.Mapperly can't know that you want path
User.FullName
of typeUser
to map to pathUser
of typestring
. the paths dont match. Instead it tries to map bothUser
members together. This fails because it doesn't know how to convert fromUser
->string
. I suggest you useMapProperty
docs or define how to convert fromstring
->User
andUser
->string