Infrastructure.Mapping
1.0.0
dotnet add package Infrastructure.Mapping --version 1.0.0
NuGet\Install-Package Infrastructure.Mapping -Version 1.0.0
<PackageReference Include="Infrastructure.Mapping" Version="1.0.0" />
<PackageVersion Include="Infrastructure.Mapping" Version="1.0.0" />
<PackageReference Include="Infrastructure.Mapping" />
paket add Infrastructure.Mapping --version 1.0.0
#r "nuget: Infrastructure.Mapping, 1.0.0"
#:package Infrastructure.Mapping@1.0.0
#addin nuget:?package=Infrastructure.Mapping&version=1.0.0
#tool nuget:?package=Infrastructure.Mapping&version=1.0.0
About
The Infrastructure.Mapping package provides a flexible object mapping mechanism for transforming data between application layers (e.g., database entities to API models), supporting:
a) Simple TSource → TDestination transformations;
b) Mapping with additional data (TData);
c) Collection processing.
How to Use
- Define Entities and Models
Entities (from DB):
public class DepartmentEntity
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
public class EmployeeEntity
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public int DepartmentId { get; set; }
}
Models (for API):
public class DepartmentModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public IReadOnlyCollection<EmployeeModel> Employees { get; set; } = [];
}
public class EmployeeModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
- Create Mappers
Employee mapper (simple mapping):
public class EmployeeMapper : IMapper<EmployeeEntity, EmployeeModel>
{
public EmployeeModel Map(EmployeeEntity source)
{
ArgumentNullException.ThrowIfNull(source, nameof(source));
return new EmployeeModel
{
Id = source.Id,
Name = source.Name
};
}
}
Department mapper (mapping with employee data):
public class DepartmentMapper : IDataMapper<DepartmentEntity, DepartmentModel, EmployeeEntity>
{
private readonly IMapper<EmployeeEntity, EmployeeModel> _employeeMapper;
public DepartmentMapper(IMapper<EmployeeEntity, EmployeeModel> employeeMapper)
{
_employeeMapper = employeeMapper;
}
public DepartmentModel Map(DepartmentEntity departmentEntity,
IEnumerable<EmployeeEntity> employeeEntities)
{
var employees = _employeeMapper.Map(
employeeEntities.Where(e => e.DepartmentId == departmentEntity.Id)
);
return new DepartmentModel
{
Id = departmentEntity.Id,
Name = departmentEntity.Name,
Employees = employees
};
}
}
- Apply Mapping
Simple code:
// Source data
var employees = new List<EmployeeEntity>
{
new EmployeeEntity { Id = 1, Name = "Employee1", DepartmentId = 1 },
new EmployeeEntity { Id = 2, Name = "Employee2", DepartmentId = 1 },
};
var departments = new List<DepartmentEntity>
{
new DepartmentEntity { Id = 1, Name = "Department1" },
new DepartmentEntity { Id = 2, Name = "Department2" }
};
// Create mappers
var employeeMapper = new EmployeeMapper();
var departmentMapper = new DepartmentMapper(employeeMapper);
// Map collections
var departmentModels = departmentMapper.Map(departments, employees);
Result:
The departmentModels collection contains DepartmentModel objects, where each department includes its employees.
Main Types
The main types provided by this library are:
Infrastructure.Mapping.Interfaces.IMapper<TSource, TDestination>
*(Defines a contract for mapping objects from one type to another.
Supports simple one‑to‑one transformations)*
Infrastructure.Mapping.Interfaces.IDataMapper<TSource, TDestination, TData>
*(Extends basic mapping with support for additional data (TData).
Useful when transformation logic depends on external context or related entities.)*
Infrastructure.Mapping.Extensions.CollectionMappingExtensions
*(Static class providing extension methods for IMapper and IDataMapper.
Enables bulk mapping of collections to IReadOnlyCollection<TDestination>.)*
Feedback & Contributing
Infrastructure.Mapping is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Infrastructure.Mapping:
| Package | Downloads |
|---|---|
|
Infrastructure.Mapping.AutoMapper
The package providing core components for object mapping using packet Automapper in applications. Simplifies mapping implementation by offering reusable abstractions and helpers. Enables developers to focus on business logic rather than low‑level mapping details. Future updates will expand functionality with additional utilities and mapping patterns. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 141 | 1/5/2026 |