Making.Mapster
1.0.1-preview
This is a prerelease version of Making.Mapster.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Making.Mapster --version 1.0.1-preview
NuGet\Install-Package Making.Mapster -Version 1.0.1-preview
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="Making.Mapster" Version="1.0.1-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Making.Mapster" Version="1.0.1-preview" />
<PackageReference Include="Making.Mapster" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Making.Mapster --version 1.0.1-preview
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Making.Mapster, 1.0.1-preview"
#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.
#:package Making.Mapster@1.0.1-preview
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Making.Mapster&version=1.0.1-preview&prerelease
#tool nuget:?package=Making.Mapster&version=1.0.1-preview&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Making.Mapster
Mapster integration and extensions for the Making framework.
Overview
Making.Mapster provides seamless integration with Mapster object mapping library for the Making framework. It offers dependency injection setup, configuration extensions, and optimized mapping performance for domain objects, DTOs, and entities.
Features
- Mapster Integration: Easy Mapster configuration and setup
- Dependency Injection: Full DI container integration
- Performance Optimized: Pre-compiled mapping expressions
- Configuration Extensions: Fluent mapping configuration
- Type Adapters: Custom type adapters and converters
Installation
dotnet add package Making.Mapster
Usage
Register Services
services.AddMakingMapster();
Basic Mapping
public class UserService
{
private readonly IMapper _mapper;
public UserService(IMapper mapper)
{
_mapper = mapper;
}
public async Task<UserDto> GetUserAsync(int userId)
{
var user = await _userRepository.GetByIdAsync(userId);
return _mapper.Map<UserDto>(user);
}
public async Task<User> CreateUserAsync(CreateUserRequest request)
{
var user = _mapper.Map<User>(request);
await _userRepository.CreateAsync(user);
return user;
}
}
Custom Mapping Configuration
public class MappingProfile : IRegister
{
public void Register(TypeAdapterConfig config)
{
// Basic mapping
config.NewConfig<User, UserDto>()
.Map(dest => dest.FullName, src => $"{src.FirstName} {src.LastName}")
.Map(dest => dest.Age, src => DateTime.Now.Year - src.BirthYear);
// Ignore properties
config.NewConfig<CreateUserRequest, User>()
.Ignore(dest => dest.Id)
.Ignore(dest => dest.CreatedAt);
// Complex mapping
config.NewConfig<Order, OrderDto>()
.Map(dest => dest.TotalAmount, src => src.Items.Sum(i => i.Price * i.Quantity))
.Map(dest => dest.ItemCount, src => src.Items.Count);
}
}
// Register mapping profile
services.AddMakingMapster(config =>
{
config.Scan(typeof(MappingProfile).Assembly);
});
Collection Mapping
public class ProductService
{
private readonly IMapper _mapper;
public ProductService(IMapper mapper)
{
_mapper = mapper;
}
public async Task<List<ProductDto>> GetProductsAsync()
{
var products = await _productRepository.GetAllAsync();
return _mapper.Map<List<ProductDto>>(products);
}
public async Task<PagedResult<ProductDto>> GetPagedProductsAsync(int page, int size)
{
var products = await _productRepository.GetPagedAsync(page, size);
var totalCount = await _productRepository.GetCountAsync();
return new PagedResult<ProductDto>
{
Items = _mapper.Map<List<ProductDto>>(products),
TotalCount = totalCount,
PageNumber = page,
PageSize = size
};
}
}
Requirements
- .NET Standard 2.0+
- Mapster
- Microsoft.Extensions.DependencyInjection.Abstractions
License
This project is part of the Making framework.
Product | Versions 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. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Mapster (>= 7.4.2-pre02)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.6)
-
net9.0
- Mapster (>= 7.4.2-pre02)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.9-preview | 118 | 8/20/2025 |
1.0.8-preview | 109 | 8/20/2025 |
1.0.6-preview | 114 | 8/19/2025 |
1.0.4-preview | 116 | 8/10/2025 |
1.0.1-preview | 331 | 7/25/2025 |
1.0.0-preview | 399 | 7/25/2025 |