Mlapper-Mapper
1.1.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Mlapper-Mapper --version 1.1.1
NuGet\Install-Package Mlapper-Mapper -Version 1.1.1
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="Mlapper-Mapper" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mlapper-Mapper" Version="1.1.1" />
<PackageReference Include="Mlapper-Mapper" />
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 Mlapper-Mapper --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Mlapper-Mapper, 1.1.1"
#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 Mlapper-Mapper@1.1.1
#: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=Mlapper-Mapper&version=1.1.1
#tool nuget:?package=Mlapper-Mapper&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Mlapper-Mapper
A lightweight object-to-object mapping library for .NET applications.
Features
- Simple configuration API
- Automatic property discovery and mapping
- Custom property mapping with lambda expressions
- Type conversion support
- Fluent configuration interface
Installation
dotnet add package Mlapper-Mapper
Basic Usage
// Set up your mapping configuration
var config = new MapperConfiguration();
// Create map with automatic property discovery
config.CreateMap<CustomerDto, Customer>();
// Add custom property mapping
config.ForMember<CustomerDto, Customer>(
dest => dest.FullName,
src => src.FirstName + " " + src.LastName
);
// Create mapper
var mapper = config.CreateMapper();
// Map objects
var customerDto = new CustomerDto { FirstName = "John", LastName = "Doe", Age = 30 };
var customer = mapper.Map<CustomerDto, Customer>(customerDto);
// Map to existing object
var existingCustomer = new Customer();
mapper.Map(customerDto, existingCustomer);
For your web projects, add it as a service to your Program file
builder.Services.AddSingleton(sp =>
{
var config = new MapperConfiguration();
config.CreateMap<ProductDto, Product>();
return config.CreateMapper();
});
Advanced Usage
Null Handling
The library handles null values appropriately:
// Returns default(Customer) (null for reference types)
var result = mapper.Map<CustomerDto, Customer>(null);
// Returns the existing destination object
var keptObject = mapper.Map(null, existingCustomer);
Type Conversions
Automatic type conversions are supported for compatible types:
- Numeric conversions (int → long, float → double)
- String to numeric conversions
- Numeric to string conversions
- Any assignment-compatible types
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details
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 was computed. 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
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.