How to map a property on to a collection of many? #848
-
Hello, I am experimenting with Mapperly I'm extremely new to the library, but it seems really easy to get going, but I've hit a snag, I would like to be able to map Bellow you will find the example code I've been playing with [Mapper]
public static partial class DeviceMapperly
{
public static Destination MapImport(Import request)
{
var destination = ImportToDestination(request);
foreach (var destinationItem in destination.Items)
destinationItem.Creator = request.Creator;
return destination;
}
public static partial Destination ImportToDestination(Import request);
}
public class Import
{
public string Creator { get; set; }
public ICollection<ImportItem> Items;
}
public class ImportItem
{
public string Name { get; set; }
public string Description { get; set; }
}
public class Destination
{
public ICollection<DestinationItem> Items;
}
public class DestinationItem
{
public string Creator { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTimeOffset CreatedOn { get; set; }
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Mapperly does not support unflattening into enumerable items. You need to do this manually as you have done it. |
Beta Was this translation helpful? Give feedback.
Mapperly does not support unflattening into enumerable items. You need to do this manually as you have done it.