tags:

views:

510

answers:

1

I'm trying to map an array into an ICollection of type <T>.

Basically I want to be able to do:

Mapper.CreateMap<X[], Y>();

Where Y is Collection<T>

Any ideas?

Thanks.

+2  A: 

You don't need to setup your mapping for collections, just the element types. So just:

Mapper.CreateMap<X, Y>();
Mapper.Map<X[], Collection<Y>>(objectToMap);

See here for more info: http://automapper.codeplex.com/wikipage?title=Lists%20and%20Arrays&amp;referringTitle=Home

Drew Freyling
What about if I want to map a string[] to a Y? e.g. where each string in the array will map to a different property of Y?
Steve Dunn