Closed JonPSmith closed 8 years ago
Dear @JonPSmith,
You are right if you don't use Mapper.Compile() - then it compiles first time, caches it and reuses saved cache next time.
.CompileTo(CompilationType...) - only affects how it would be compiled when you call Mapper.Compile(). As there are 2 kind of compilations - only for source (destination object instance will be created) and with destination (destination object instance will be reused - in order to save memory).
Hi,
I am thinking of changing over some of my libraries, like GenericServices, from using AutoMapper to ExpressMapper.
My libraries handles the setup of the mappings on first use if you haven't set them up yourself. I do this because it is very hard to remember/maintain all the mappings you have set up, which could be hundreds. I think most users let GenericServices setup the mappings on first use, I certainly do, which is why swapping to ExpressMapper with its quicker setup is attractive.
My first question is: you strongly recommend calling
Mapper.Compile()
, but if I don't what happens? Does it simply compile on first use, or is there a loss of performance?A second related question. If I apply the
.CompileTo(CompilationTypes...)
to a registration and don't callMapper.Compile()
then does it still obey theCompileTo
settings, or doesn't it matter?