Map List and flatten it #1195
-
I have these classes:
So, I want to map all Trip Subscribers to TripResult SubscribersIds like: trip.Subscribers.ConvertAll(s => s.Id) Is it possible to implement in Mapperly? |
Beta Was this translation helpful? Give feedback.
Answered by
TimothyMakkison
Mar 23, 2024
Replies: 1 comment
-
I'd recommend using a before/after map for this. [Mapper]
public static class MyMapper
{
public static TripResult MapTrip(Trip source)
{
var result = InternalMapTrip(source);
result.SubscribersIds = source.Subscribers.ConvertAll(s => s.Id);
return result;
}
[MapperIgnoreTarget("SubscribersIds")]
public static partial TripResult InternalMapTrip(Trip source);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fpetrov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd recommend using a before/after map for this.