SimpleAutoMapper 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleAutoMapper --version 1.2.0                
NuGet\Install-Package SimpleAutoMapper -Version 1.2.0                
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="SimpleAutoMapper" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleAutoMapper --version 1.2.0                
#r "nuget: SimpleAutoMapper, 1.2.0"                
#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 SimpleAutoMapper as a Cake Addin
#addin nuget:?package=SimpleAutoMapper&version=1.2.0

// Install SimpleAutoMapper as a Cake Tool
#tool nuget:?package=SimpleAutoMapper&version=1.2.0                

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.0

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 of ResponseModel, maps the properties from request, 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 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. 
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.

Version Downloads Last updated
1.2.5 189 8/25/2024
1.2.0 109 8/25/2024
1.1.3 223 3/12/2024
1.1.2 130 3/10/2024
1.1.1 140 3/10/2024
1.1.0 129 3/9/2024
1.0.0 129 3/9/2024