OLT.DataAdapters.AutoMapper
is a library that integrates AutoMapper with the OLT DataAdapters framework. It provides utilities and extensions to simplify the configuration and usage of AutoMapper within OLT-based applications.
- Seamless integration with AutoMapper.
- Easy configuration of AutoMapper profiles and mappings.
- Includes utilities for assembly scanning for maps.
To install the package, add the following package reference to your project file:
dotnet add package OLT.DataAdapters.AutoMapper
To install the extensions package, add the following package reference to your project file:
dotnet add package OLT.Extensions.DependencyInjection.AutoMapper
// Inject IOltAdapterResolver
// Checks to see if can project IQueryable
adapterResolver.CanProjectTo<PersonEntity, PersonModel>();
//Simple Map
var person = adapterResolver.Map<PersonEntity, PersonModel>(entity, new PersonModel());
var queryable = Context.People.GetAll();
var records = adapterResolver.ProjectTo<PersonEntity, PersonModel>(queryable);
public class PersonEntityToPersonModelAdapter : OltAdapter<PersonEntity, PersonModel>
{
public override void Map(PersonEntity source, PersonModel destination)
{
destination.Name = new PersonName
{
First = source.FirstName,
Last = source.LastName,
};
}
public override void Map(PersonModel source, PersonEntity destination)
{
destination.FirstName = source.Name.First;
destination.LastName = source.Name.Last;
}
}