Question

There are two types of exceptions in Automapper and I can´t find information anywhere on how to use them.

The exceptions are AutoMapperMappingException and AutoMapperConfigurationException

Does anybody know the difference of these two and how I should set up try/catch for them?

Était-ce utile?

La solution

Check the source code.

AutoMapperConfigurationException is used when the mapping profiles are loaded up by AutoMapper. Its thrown my Automapper when performing a configuration checks.

    [Test]
    public void Mapper_AssertConfigurationIsValid_Expect_No_Exceptions()
    {
        AutoMapper.Mapper.AssertConfigurationIsValid();
    }

AutoMapperMappingException is used during "runtime"...that is when the actual mapping code is run to turn your source dto to your destination dto.

HTH.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top