EntitiesMapper 1.0.7

dotnet add package EntitiesMapper --version 1.0.7
NuGet\Install-Package EntitiesMapper -Version 1.0.7
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="EntitiesMapper" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EntitiesMapper --version 1.0.7
#r "nuget: EntitiesMapper, 1.0.7"
#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 EntitiesMapper as a Cake Addin
#addin nuget:?package=EntitiesMapper&version=1.0.7

// Install EntitiesMapper as a Cake Tool
#tool nuget:?package=EntitiesMapper&version=1.0.7

EntitiesMapper

Package that allows mapping between classes in a very simple way.

Features

  • Map classes
  • Dependency injection
  • Developed with .NET Core 6

How to install

To install this nuget package:

  dotnet add package EntitiesMapper

Usage/Examples

1 scenario: equals classes

public class PersonEntity
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public int Age { get; set; }
    public int BirthdayYear { get; set; }
    public string Address { get; set; }
}

public class PersonDto
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public int Age { get; set; }
    public int BirthdayYear { get; set; }
    public string Address { get; set; }
}

you can do this:

internal class Program
{
    static void Main(string[] args)
    {
        var entity = new PersonEntity() //source
        {
            Name = "John",
            Surname = "Doe",
            Age = 30,
            BirthdayYear = 1992,
            Address = "Via del Sole, 123"
        };
        var dto = new PersonDto(); //destination
        Mapper.CopyTo<PersonEntity, PersonDto>(entity, dto);
    }
}

3 scenario: destination class can be mapped by multiple sources classes

public class PersonEntity
{
    public string Name { get; set; }
    public string Surname { get; set; }
    public int Age { get; set; }
    public string Rule { get; set; }
    public int BirthdayYear { get; set; }
    public string Address { get; set; }
}

public class PersonEntity2
{
    public string NomeNascita { get; set; }
    public string SurnameNascita { get; set; }
    public int EtaAttuale { get; set; }
}

internal class PersonDto
{
    [MapTo(typeof(PersonEntity), "Name")]
    [MapTo(typeof(PersonEntity2), "NomeNascita")]
    public string Nome { get; set; }
    [MapTo(typeof(PersonEntity), "Surname")]
    [MapTo(typeof(PersonEntity2), "SurnameNascita")]
    public string Cognome { get; set; }
    [MapTo(typeof(PersonEntity), "Age")]
    [MapTo(typeof(PersonEntity2), "EtaAttuale")]
    public int Eta { get; set; }
    [MapTo(typeof(PersonEntity), "BirthdayYear")]
    public int AnnoNascita { get; set; }
    [MapTo(typeof(PersonEntity), "Address")]
    public string ViaResidenza { get; set; }
}

you can add multiple [MapToAttribute] on each destination property class like example and then do this:

internal class Program
{
    static void Main(string[] args)
    {
        var entity = new PersonEntity() //source
        {
            Name = "John",
            Surname = "Doe",
            Age = 30,
            BirthdayYear = 1992,
            Address = "Via del Sole, 123"
        };
        var entity2 = new PersonEntity2()
        {
            NomeNascita = "John",
            SurnameNascita = "Doe",
            EtaAttuale = 30
        };

        var dto = new PersonDto(); //destination 1
        var dto2 = new PersonDto(); //destination 2

        Mapper.CopyTo<PersonEntity, PersonDto>(entity, dto);
        Mapper.CopyTo<PersonEntity2, PersonDto>(entity2, dto2);
    }
}

You can also copy list in another of same or different type. Please visit EntitiesMapper.Tests folder for other examples.

Roadmap

  • Performance improvements

  • Mapping classes to register map properties (if you don't like using [MapToAttribute])

  • Custom properties conversion

Hi, I'm Giuseppe! 👋

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net6.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.0.7 278 10/20/2023
1.0.6 99 10/19/2023
1.0.5 119 10/17/2023
1.0.2 167 6/8/2023
1.0.1 122 6/8/2023
1.0.0 129 6/7/2023