SimpleAutoMapper 1.2.5
dotnet add package SimpleAutoMapper --version 1.2.5
NuGet\Install-Package SimpleAutoMapper -Version 1.2.5
<PackageReference Include="SimpleAutoMapper" Version="1.2.5" />
paket add SimpleAutoMapper --version 1.2.5
#r "nuget: SimpleAutoMapper, 1.2.5"
// Install SimpleAutoMapper as a Cake Addin #addin nuget:?package=SimpleAutoMapper&version=1.2.5 // Install SimpleAutoMapper as a Cake Tool #tool nuget:?package=SimpleAutoMapper&version=1.2.5
SimpleAutoMapper
SimpleAutoMapper is a lightweight and intuitive library designed to simplify object mapping in C#. With this tool, you can effortlessly map properties and nested objects between different models, making it ideal for projects that require quick and efficient object transformation.
Installation
SimpleAutoMapper is available as a NuGet package. You can install it using the NuGet Package Manager in Visual Studio or via the .NET CLI:
Install-Package SimpleAutoMapper -Version 1.2.5
Alternatively, you can download the package directly from the NuGet website at https://www.nuget.org/packages/SimpleAutoMapper.
Getting Started
To start using SimpleAutoMapper, add the following reference at the top of your file:
using SimpleAutoMapper;
var response = AutoMapper.Map<ResponseModel>(request);
In this example:
request
is the source object you want to map.ResponseModel
is the target type.- The
Map<T>
method creates a new instance ofResponseModel
, maps the properties fromrequest
, and returns the result.
Features
- Automatic Property Mapping: Automatically maps properties with matching names and types.
- Primitive Type Support: Handles basic data types, including strings, Guids, DateTimes, and nullable types.
- Recursive Mapping: Maps complex nested objects, supporting deep object hierarchies.
- List and Array Handling: Differentiates between collections of primitive types and complex objects, applying recursive mapping where needed.
- Nullable and Read-Only Handling: Manages nullable types and safely skips read-only properties.
Limitations
- Public Setters Required: Properties must have public setters to be mapped.
- Shallow Mapping for Primitive Collections: Lists and arrays of primitive types are handled without deep inspection.
- Custom Mapping Logic: No support for custom conversion logic or attribute-based mappings.
- Circular References: Circular dependencies between objects are not handled, which can cause stack overflow errors.
Usage Notes
- Ensure that complex objects are correctly initialized in nested properties to avoid null reference exceptions.
- The library uses reflection extensively; while efficient for many scenarios, it may introduce overhead in high-performance applications.
Contributing
We welcome contributions! Feel free to open issues or submit pull requests to help improve SimpleAutoMapper. For major changes, please open an issue first to discuss your proposal.
License
This project is licensed under the MIT License - see the LICENSE file for details.
We hope SimpleAutoMapper makes your object mapping simpler and more efficient! If you have any questions or suggestions, feel free to open an issue.
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. |
-
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.