OLT.DataAdapters.Abstractions 9.0.0-beta-0010

Prefix Reserved
This is a prerelease version of OLT.DataAdapters.Abstractions.
dotnet add package OLT.DataAdapters.Abstractions --version 9.0.0-beta-0010                
NuGet\Install-Package OLT.DataAdapters.Abstractions -Version 9.0.0-beta-0010                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OLT.DataAdapters.Abstractions" Version="9.0.0-beta-0010" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OLT.DataAdapters.Abstractions --version 9.0.0-beta-0010                
#r "nuget: OLT.DataAdapters.Abstractions, 9.0.0-beta-0010"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OLT.DataAdapters.Abstractions as a Cake Addin
#addin nuget:?package=OLT.DataAdapters.Abstractions&version=9.0.0-beta-0010&prerelease

// Install OLT.DataAdapters.Abstractions as a Cake Tool
#tool nuget:?package=OLT.DataAdapters.Abstractions&version=9.0.0-beta-0010&prerelease                

CI Quality Gate Status

OLT Adapter Resolver and adapters for IQueryable and paged results


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

Projection Adapter using IQueryable

public class PersonEntityToPersonModelQueryableAdapter : OltAdapter<PersonEntity, PersonModel>, IOltAdapterQueryable<PersonEntity, PersonModel>
{
	public PersonEntityToPersonModelQueryableAdapter()
	{
		this.WithOrderBy(p => p.OrderBy(o => o.FirstName).ThenBy(o => o.LastName));
	}

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

	public IQueryable<PersonModel> Map(IQueryable<PersonEntity> queryable)
	{
		return queryable.Select(entity => new PersonModel
		{
			Name = new PersonName
			{
				First = entity.FirstName,
				Last = entity.LastName,
			}
		});
	}
}


Projection Adapter using IQueryable for Paging (requires Default Order By)

public class PersonEntityToPersonModelPagedAdapter : OltAdapterPaged<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;
	}

	public override IQueryable<PersonModel> Map(IQueryable<PersonEntity> queryable)
	{
		return queryable.Select(entity => new PersonModel
		{
			Name = new PersonName
			{
				First = entity.FirstName,
				Last = entity.LastName,
			}
		});
	}

	public override IOrderedQueryable<PersonEntity> DefaultOrderBy(IQueryable<PersonEntity> queryable)
	{
		return queryable.OrderBy(p => p.LastName).ThenBy(p => p.FirstName);
	}
}

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OLT.DataAdapters.Abstractions:

Package Downloads
OLT.DataAdapters

DataAdapters Library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.0-beta-0010 49 11/25/2024
9.0.0-beta-0005 47 11/24/2024