How to map an array to multiple properties using AutoMapper?

Posted by Dror Helper on Stack Overflow See other posts from Stack Overflow or by Dror Helper
Published on 2012-04-04T14:23:09Z Indexed on 2012/04/04 17:29 UTC
Read the original article Hit count: 230

Filed under:
|

I need to map a single fixed sized array array to multiple properties. For example given this class:

public class Source
{
    public int[] ItemArray{get;set} // always 4 items
}

I want to map the array to this class

public class Dest
{
    public int Item1{get;set;}
    public int Item1{get;set;}
    public int Item1{get;set;}
    public int Item1{get;set;}
}

Is there a simple way to do it with AutoMapper (without actually mapping each individual field)?

© Stack Overflow or respective owner

Related posts about c#

Related posts about automapper