Mapping a list of classes to a list of id's #836
-
I would like to map a list of classes to a list of id's, but can't really figure out how to do this with Mapperly. Example: I want to map Parent to ParentDto, and Children should be mapped to ChildIds. public class Child
{
public long Id { get; set; }
}
public class Parent
{
public IEnumerable<Child> Children { get; set; }
}
public class ParentDto
{
public IEnumerable<long> ChildIds { get; set; }
} |
Beta Was this translation helpful? Give feedback.
Answered by
TimothyMakkison
Oct 25, 2023
Replies: 1 comment 3 replies
-
Hey, I think this can be solved with a user implemented mapper. [Mapper]
public static partial class ParentMapper
{
public static partial ParentDto MapParent(Parent source);
public static long ChildToLong(Child source) => source.Id;
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry didn't see that your members have different name 😅. You can solve this by adding a
MapProperty
attribute.