Skip to content

Registration

Dima Bezzubenkov edited this page Sep 4, 2021 · 6 revisions

After you described mappings with help of MappingsList class and put all descriptions inside of Storage instances, you need to register your mappings.

Registration stage is the only stage that is using reflection, so registration should be done at the start of your application. During registration stage all mappings will be uploaded into memory and will be available during the whole application lifecycle.

To register all mappings you need to use method Register of MappingsConfiguration class. You need to provide all assemblies where yours IMappingStorage implementations are located.

MappingsConfiguration.Register(typeof(AddressMappings).Assembly, typeof(AppartmentMappings).Assembly);

There is also a special DevTeam.QueryMappings.AspNetCore package, which helps easier integrate QueryMappings in Asp.NET Core projects:

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddQueryMappings();
    ...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    ...
    app.UseQueryMappings(typeof(CountryMappings).Assembly);
    ...
}

Clone this wiki locally