Skip to content

tarikcosovic/MorphMapper

Repository files navigation

MorphMapper

Your Effortless .NET Object-to-Object Mapper

.NET 9 License Nuget

MorphMapper is a lightweight and efficient object-to-object mapping library for .NET 9. It simplifies the process of transferring data between different types with minimal configuration. Say goodbye to repetitive manual mapping code and embrace the elegance of automatic property mapping.

Features

  • Automatic Property Mapping: Maps properties with the same name and compatible types by default.
  • Type Conversion: Handles automatic conversion between compatible types.
  • Ignoring Properties: Easily exclude specific properties from the mapping process.
  • Lightweight and Performant: Designed with efficiency in mind, minimizing overhead.
  • .NET 9 Support: Built specifically for the latest .NET runtime.

Installation

Coming soon: You can install MorphMapper via NuGet Package Manager:

Install-Package MorphMapper

Quick Start

Initialize the mapper and the configuration

var mapperConfig = new MapperConfiguration(Assembly.GetExecutingAssembly()); 

var mapper = new Mapper(mapperConfig);

var result = mapper.Map<HouseDto, House>(sourceObjectMock);

In the HouseMapper.cs just override the Configure method

public class HouseMapper : Mapping<HouseDto, House>
{
    public override Mapping<HouseDto, House> Configure(Mapping<HouseDto, House> mapping)
    {
        mapping.ForMember(x => x.Id, y => y.MapFrom(x => x.Id));
        mapping.ForMember(x => x.Name, y => y.MapFrom(x => x.Name));
        mapping.ForMember(x => x.Description, y => y.MapFrom(x => x.Description));

        return mapping;
    }
}

Contributing

Contributions are more then welcome, please feel free to submit pull requests, report issues, or suggest new features.

License

MorphMapper is licensed under the MIT License.

About

Your Effortless .NET Object-to-Object Mapper Library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages