Skip to content

How to map array of strongly typed objects in a one liner? #57

@philippfx

Description

@philippfx

Hi,

Great library, I love it!

I am stuck at mapping an array of objects in a one liner. I want to achive something like this (pseudo code):

let destinationArray: DestinationType[]
      = automapper.map(SourceType.name, DestinationType.name, sourceArray)

where sourceArray: SourceType[]

How can I map it in a one liner?

So far, my workaround is looping through the sourceArray and mapping each element individually:

const destinationArray: DestinationType[] = new Array(sourceArray.length);
for (let i = 0; i < sourceArray.length; i++) {
  destinationArray[i] = automapper.map(SourceType.name, DestinationType.name, sourceArray[i]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions