Automapify 1.0.18

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

// Install Automapify as a Cake Tool
#tool nuget:?package=Automapify&version=1.0.18                

Automapify

This dotnet library facilitates object mappings without the need for service setup or configuration.

Basic Usage

There are two methods for utilizing this tool: Attributes and Configuration

Attributes
  • Specify the property name from the source in the destination object using the MapProperty attribute

          public int Id { get; set; }
    
          public string Name { get; set; }
    
          public int Age { get; set; }
    
          [MapProperty("DateOfBirth")]
          public DateTime DOB { get; set; }
    
          public bool IsDeleted { get; set; }
    
          public Classroom Room {get; set; }
    
Map to a new object
    var studentDto = student1.Map<Student,StudentDto>();
Map to an existing object
  studentDto.Map<Student,StudentDto>(student1);
Configuration
  • Establish a configuration to illustrate the mapping of values.
     public static class MappingService
   {
       public static MapifyConfiguration<Student,StudentDtos> StudentConfig()
       {
           return new MapifyConfigurationBuilder<Student, StudentDto>()
               .Map(d => d.Name, s => $"{s.FirstName} {s.LastName}")
               .Map(d => d.Age, s => s.DateOfBirth.ToAge())
               .Map(d=>d.DOB, s => s.DateOfBirth)
               .Map(d=>d.IsDeleted, s => false)
               .Map(d=>d.Classroom, s=> s.Room)
               .CreateConfig();
       }
   }
Map to a new object
  var studentDto = student.Map<Student,StudentDto>(MappingService.StudentConfig());
Map to an existing object
   studentDto.Map<Student,StudentDto>(student1,MappingService.StudentConfig());
Many to one/many mapping

Automapify now supports many to many and many to one object mapping. You can utilize that by either using the conifguration or attributes.

Using MapProperty attribute
  • Specify the property name from the source in the destination object using the MapProperty attribute

          public int Id { get; set; }
    
          public string Name { get; set; }
    
          public int Age { get; set; }
    
          [MapProperty("DateOfBirth")]
          public DateTime DOB { get; set; }
    
          public bool IsDeleted { get; set; }
    
          public Classroom Room {get; set; }
    
Map from objects to objects (Many-to-many mapping)
  • Map to a new object
    var studentDtos = student.Map<List<Student>, List<StudentDto>>();
    
  • Map to an existing object
    studentDtos.Map(students); 
    
Map from object to objects (One-to-many mapping)
  • Map to a new object
    var studentDtos = student.Map<Student, List<StudentDto>>();
    
  • Map to an existing object
    studentDtos.Map(student); 
    
Using Configuration
  • Establish a configuration to illustrate the mapping of values.
     public static class MappingService
   {
       public static MapifyConfiguration<Student,StudentDtos> StudentConfig()
       {
           return new MapifyConfigurationBuilder<Student, StudentDto>()
               .Map(d => d.Name, s => $"{s.FirstName} {s.LastName}")
               .Map(d => d.Age, s => s.DateOfBirth.ToAge())
               .Map(d=>d.DOB, s => s.DateOfBirth)
               .Map(d=>d.IsDeleted, s => false)
               .Map(d=>d.Classroom, s=> s.Room)
               .CreateConfig();
       }
   }
Map from objects to objects (Many-to-many mapping)
  • Map to a new object
    var studentDtos = student.Map<List<Student>, List<StudentDto>>(MappingService.StudentConfig());
    
  • Map to an existing object
    studentDtos.Map(students,MappingService.StudentConfig()); 
    
Map from object to objects (One-to-many mapping)
  • Map to a new object
    var studentDtos = student.Map<Student, List<StudentDto>>(MappingService.StudentConfig());
    
  • Map to an existing object
    studentDtos.Map(student,MappingService.StudentConfig()); 
    
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.22 209 9/5/2024
1.0.18 123 8/28/2024
1.0.16 148 2/2/2024