1

I'm running a performance test for AutoMapper, FasMapper, ValueInjecter and EmitMapper and I'm facing problem only with EmitMapper and ValueInjecter when I try to map list of types IList<T>

That's the code I user for all mappers:

adapter.Adapt<IList<VacationModel>, IList<VacationDto>>(source));

That is my adapter implementation for EmitMapper:

    public TTarget Adapt<TSource, TTarget>(TSource source)
    {
        return ObjectMapperManager.DefaultInstance.GetMapper<TSource, TTarget>().Map(source);
    }

That is for ValueInjecter:

    public TTarget Adapt<TSource, TTarget>(TSource source)
    {
        return Mapper.Map<TSource, TTarget>(source);
    }

I have a single interface that holds the method Adapt<TSource, TTarget>(TSource source)

What am I doning wrong? It's working for AutoMapper and FastMapper tho! If I change to List<T> it works for all mappers.

DAG
  • 2,460
  • 5
  • 33
  • 61
  • 1
    for valueinjecter you'll have to do a loop if you want to map a collection – Omu Dec 24 '15 at 16:48
  • Ok, it works, but after that ValueInjecter lost by far winning only agains AutoMapper. Do you think this is going to be improved? – DAG Dec 24 '15 at 17:24
  • depends how you define Mapper.AddMap, you could use InjectFrom or you could do a.p1 = b.p1; ( if performance if very important for that particular mapping); you can look here: https://github.com/omuleanu/ValueInjecter/blob/master/Tests/MapperTests.cs see the commented code inside AddMap – Omu Dec 24 '15 at 18:02
  • Yeah, so, it's not about a particular mapping...it's about a decision which mapper we should use. As we use an abstract `ITypeAdapter`, this should be as generic as possible in case we need to switch the mapper in the future (this is used in several projects in our company, so if we switch the mapper, we don't want side effects). If you have an idea of how to create an abstraction for mappings that also fits for ValueInjecter, let me know. I was really impressed of ValueInjecter...Merry Xmas! – DAG Dec 24 '15 at 19:28

0 Answers0