AutoMapper icon indicating copy to clipboard operation
AutoMapper copied to clipboard

How is mapping of nested properties in collections performed?

Open Neutrino-Sunset opened this issue 5 years ago • 1 comments

Given this

var test1 = {
   'array1' : [
      {
         'prop1': 42,
         'prop2': 43
      },
      {
         'prop1': 42,
         'prop2': 43
      },
      {
         'prop1': 42,
         'prop2': 43
      }
   ]
};

How do I create a mapping that adds another property to the objects in the collection?

      automapper.createMap('a', 'b')
         .forMember('array1.prop3 ???', function() { return 56; });

Neutrino-Sunset avatar May 22 '19 10:05 Neutrino-Sunset

I think you can't. Only way I've been able to do this, is to create a mapping for the type in the array, and then iterate over the array and call automapper.map individually.

shaycraft avatar Aug 14 '19 15:08 shaycraft