Skip to content

[Mapping by code] In ModelMapper.AddMapping, evaluate to replace Activator.CreateInstance with a compiled lambda to increase performance. #2838

@pasqualedante

Description

@pasqualedante

In one app, I have 360 mapped types. NH configuration was created as show under:

var map = new ModelMapper();
map.AddMappings(types);

var hbm = map.CompileMappingForAllExplicitlyAddedEntities();
hbm.autoimport = false;

configuration.AddMapping(hbm);

The time to execute the map.AddMappings (types) statement; is approximately 1268 ms and is related to running Activator.CreateInstance 360 times. Maybe by converting Activator.CreateInstance to compiled lambda we can get better performance?

modelmapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions