Map a collection and additional properties using Mapster with multiple sources

50 Views Asked by At

I have an enumerable which needs to be mapped to an entity, with additional fields from a different source. These additional fields will have the same values for the entire collection.

How can I map a collection using this config. Or is there another way to map a collection using Mapster

config.NewConfig<(Product, AditionalFields), ProductRecord>()
                .Map(dest => dest, src => src.Item1)
                     .Map(dest => dest.publicationId, src => src.Item2.publicationId)
                     .Map(dest => dest.publicationEndDate, src => src.Item2.publicationEndDate)

I have used

list.AsQueryable().ProjectToType<EntityA>().ToList() 

to map a list, looking for a way to do this with multiple sources.

My source is a collection and an object with some fields which will be same for all the objects in the source.

0

There are 0 best solutions below