Skip to content

OuterlimitsTech/olt-automapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Quality Gate Status

OLT.DataAdapters.AutoMapper

Overview

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.

Features

  • Seamless integration with AutoMapper.
  • Easy configuration of AutoMapper profiles and mappings.
  • Includes utilities for assembly scanning for maps.

Getting Started

Installation

To install the Nuget package, add the following package reference to your project file:

dotnet add package OLT.DataAdapters.AutoMapper

To install the Nuget extensions package, add the following package reference to your project file:

dotnet add package OLT.Extensions.DependencyInjection.AutoMapper

Usage

OLT Adapter Resolver and adapters for 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);

Simple Adapater

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;
	}
}

About

AutoMapper Extensions for OLT DataAdapters

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages