xiaolizi007
3/25/2017 - 12:17 PM

AutoMapper 6.0 Demo

AutoMapper 6.0 #csharp

  Mapper.Initialize(cfg => cfg.CreateMap<Source, Destination>());

    var sources = new[]
        {
            new Source { Value = 5 },
            new Source { Value = 6 },
            new Source { Value = 7 }
        };

    IEnumerable<Destination> ienumerableDest = Mapper.Map<Source[], IEnumerable<Destination>>(sources);
    ICollection<Destination> icollectionDest = Mapper.Map<Source[], ICollection<Destination>>(sources);
    IList<Destination> ilistDest = Mapper.Map<Source[], IList<Destination>>(sources);
    List<Destination> listDest = Mapper.Map<Source[], List<Destination>>(sources);
    Destination[] arrayDest = Mapper.Map<Source[], Destination[]>(sources);