From a72b01ab20d6efb896c4bfc7d76ec16cb54c1ef1 Mon Sep 17 00:00:00 2001 From: maliming Date: Sat, 13 Sep 2025 13:30:30 +0800 Subject: [PATCH] Clarify collection mapping behavior in docs Added a note explaining that Mapperly preserves null values for collection properties during mapping, unlike AutoMapper which maps them to empty collections. --- docs/en/framework/infrastructure/object-to-object-mapping.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/framework/infrastructure/object-to-object-mapping.md b/docs/en/framework/infrastructure/object-to-object-mapping.md index 01484b31fe..8c9a0453df 100644 --- a/docs/en/framework/infrastructure/object-to-object-mapping.md +++ b/docs/en/framework/infrastructure/object-to-object-mapping.md @@ -337,6 +337,8 @@ var users = await _userRepository.GetListAsync(); // returns List var dtos = ObjectMapper.Map, List>(users); // creates List ```` +> When mapping a collection property, if the source value is null Mapperly will keep the destination value as null. This is different from AutoMapper, which will map the destination field to an empty collection. + ### Nested Mapping When working with nested object mapping, there's an important limitation to be aware of. If you have separate mappers for nested types like in the example below, the parent mapper (`SourceTypeToDestinationTypeMapper`) will not automatically use the nested mapper (`SourceNestedTypeToDestinationNestedTypeMapper`) to handle the mapping of nested properties. This means that configurations like the `MapperIgnoreTarget` attribute on the nested mapper will be ignored during the parent mapping operation.