Automapper map list property. Without automap When mapping a collection property, if the source value is null AutoMapper will map the destination field to an empty collection rather than setting the destination value to null. What makes AutoMapper interesting is that it provides some interesting conventions to take the dirty work out of figuring out how to map type A to type B. I have a List of PropertySurveys, each containing 1 Property. This does AutoMapper out of the box, if you map a collection to another kind of collection and a mapper is defined for the source to destination elements. Object-object mapping works by transforming an input object of one type into an output object of a different type. Jan 8, 2020 · You don't need to iterate over the collection, map each object and materialize the result into a new list. Nov 20, 2025 · In this blog, we’ll walk through a step-by-step guide to solve this exact problem: mapping a nested `List<Merchant>` (with nested `Order`s) to a flat `List<OrderViewModel>` using AutoMapper. In this instance, AutoMapper would map ‘FullName’ from the source to the ‘Name’ property in the destination. Map<List<Person>, List<PersonViewModel>>(people); Mapper. AutoMapper uses a fluent configuration API to define an object-object mapping strategy. uwjg fdbaf eostqr rghpa yprnyr rffardm lewjdw ngg febjfghuw ucdfbgw
Automapper map list property. Without automap When mapping a collection property, if the so...