AIMapper 1.0.0

dotnet add package AIMapper --version 1.0.0
                    
NuGet\Install-Package AIMapper -Version 1.0.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="AIMapper" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AIMapper" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AIMapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AIMapper --version 1.0.0
                    
#r "nuget: AIMapper, 1.0.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.
#:package AIMapper@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AIMapper&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AIMapper&version=1.0.0
                    
Install as a Cake Tool

AIMapper Logo

AIMapper

Fleksibel, intuitif, dan performa tinggi untuk object mapping di .NET

.NET License: MIT Status: Production Ready


✨ Tentang AIMapper

AIMapper adalah library object-to-object mapping untuk .NET 8 yang mendukung konfigurasi berbasis atribut maupun fluent interface.
Dirancang sebagai alternatif ringan AutoMapper, AIMapper mendukung:

  • Flattening & unflattening properti nested
  • Mapping berbasis atribut [Map]
  • Konfigurasi fluent (cfg.ForMember(...))
  • Null substitute, converter, condition, ignore
  • Paging async dan collection projection
  • ReverseMap dan mapping profile terpusat
  • Tanpa konfigurasi runtime

📦 Instalasi

dotnet add package AIMapper

🚀 Quick Start

1. Definisikan Model & DTO

public class User {
    public int Id { get; set; }
    public string? Name { get; set; }
    public UserProfile? Profile { get; set; }
}

public class UserProfile {
    public string? Address { get; set; }
}

public class UserDto {
    public int Id { get; set; }
    public string? Name { get; set; }
    public string? Address { get; set; }
}

2. Tambahkan ke DI

services.AddAIMapper();

3. Konfigurasi Mapping

mapper.Configure<User, UserDto>(cfg => {
    cfg.ForMember("Address", o => o.CustomPath = "Profile.Address");
});

4. Mapping Object & Koleksi

var dto = mapper.Map<User, UserDto>(user);
var dtos = users.ProjectTo<User, UserDto>(mapper).ToList();

🎯 Fitur Fluent Mapping

Fitur Contoh
Ignore cfg.ForMember("Name", o => o.Ignore());
CustomPath cfg.ForMember("Address", o => o.CustomPath = "Profile.Address");
Condition cfg.ForMember("IsActive", o => o.Condition<User, UserDto>((src, dest) => src.Status == StatusEnum.Active));
NullSubstitute cfg.ForMember("Email", o => o.NullSubstitute("default@email.com"));
ValueConverter cfg.ForMember("Registered", o => o.ConvertUsing<DateTime?, string?>(dt => dt?.ToString("yyyy-MM-dd")));
BeforeMap / AfterMap cfg.BeforeMap(...); cfg.AfterMap(...);
ReverseMap cfg.ReverseMap((Mapper)mapper);
Paging Async var pageDto = await users.ProjectToPagedListAsync<User, UserDto>(mapper, 1, 10);

🔥 Contoh MappingProfile

public class UserProfileMap : MapperProfile
{
    public override void Configure(IMapper mapper)
    {
        mapper.Configure<User, UserDto>(cfg =>
        {
            cfg.ForMember("Address", o => o.CustomPath = "Profile.Address");
            cfg.ForMember("Email", o => o.NullSubstitute("default@email.com"));
            cfg.ForMember("Registered", o => o.ConvertUsing<DateTime?, string?>(dt => dt?.ToString("yyyy-MM-dd")));
            cfg.ForMember("IsActive", o => o.Condition<User, UserDto>((src, dest) => src.Status == StatusEnum.Active));
            cfg.ForMember("Name", o => o.Ignore());
            cfg.BeforeMap((src, dest) => dest.Point = src.Point ?? 0);
            cfg.AfterMap((src, dest) => dest.Name = src.Name?.ToUpper());
            cfg.ReverseMap((Mapper)mapper);
        });

        mapper.Configure<Order, OrderDto>(cfg =>
        {
            cfg.ForMember("CustomerName", o => o.CustomPath = "Customer.Name");
            cfg.ForMember("Total", o => o.NullSubstitute(0));
            cfg.AfterMap((src, dest) => dest.IsPaid = src.Status == OrderStatus.Paid);
            cfg.ReverseMap((Mapper)mapper);
        });
    }
}

Registrasi MappingProfile:

mapper.ApplyProfilesFromCurrentAssembly();

📁 Contoh Lengkap

Lihat AIMapperSampleDemo.cs di project AIMapper.SampleApp untuk contoh implementasi penuh.


📄 Lisensi

Proyek ini menggunakan lisensi MIT License.

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0 364 7/25/2025

Versi 1.0.0 AIMapper:
- Support untuk mapping berbasis atribut
- Flattening dan unflattening property kompleks
- NullSubstitute, Condition, dan Converter berbasis MapAttribute
- Nama class dan interface konsisten dengan AutoMapper