mapperly-patterns

Implements Mapperly entity-DTO mapping classes using MapperBase from Abp.Mapperly in ASP.NET Zero applications.

Updated May 22, 2026
One-click install
npx skills add https://github.com/shakesoft/timekeeper --skill mapperly-patterns-shakesoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mapperly-patterns
Source: https://github.com/shakesoft/timekeeper/tree/main/.cursor/skills/mapperly-patterns
Command: npx skills add https://github.com/shakesoft/timekeeper --skill mapperly-patterns-shakesoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent entity-to-DTO mapping code in ASP.NET Zero projects requires knowing the exact Mapperly conventions, file locations, and base classes. This Skill provides the established patterns so generated mappers compile correctly and follow team conventions. ## Core Features & Use Cases - Standard Mapper Generation: Creates partial mapper classes inheriting from MapperBase<TSource, TDest> with the [Mapper] attribute and both Map overrides. - Manual Mapping Guidance: Shows how to write non-partial manual mappings for protected setters (like EntityDto Id) and calculated properties. - Property Ignoring: Demonstrates MapperIgnoreTarget for excluding properties such as passwords from DTO mapping. - Use Case: When adding a new Product feature, generate the four typical mappers (ListDto, EditDto both directions, CreateDto) in Application/Mappers/ProductMappers.cs and consume them via ObjectMapper in app services. ## Quick Start Generate Mapperly mapper classes for the Product entity and its ListDto, EditDto, and CreateDto following the project conventions.

Frequently Asked Questions about mapperly-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Mapperly mapper in an ASP.NET Zero project?▼

Create a partial class in Application/Mappers/{Feature}Mappers.cs that inherits MapperBase<TSource, TDest> from Abp.Mapperly and add the [Mapper] attribute from Riok.Mapperly.Abstractions. Declare both partial Map overrides, and Mapperly generates the implementation at compile time.

How to map DTO to entity with Mapperly and ABP ObjectMapper?▼

Mappers are auto-registered, so inject nothing extra and call ObjectMapper.Map<Product>(createDto) for creates or ObjectMapper.Map(editDto, existingEntity) for updates. List mapping works via ObjectMapper.Map<List<ProductListDto>>(entities).

Why does Mapperly fail to map protected setters like EntityDto Id?▼

Mapperly source generation cannot assign protected setters such as the Id on EntityDto base classes. Write a manual non-partial Map override that constructs the DTO and sets properties directly instead of relying on generated code.

How do I ignore a property when mapping with Mapperly?▼

Apply [MapperIgnoreTarget(nameof(UserListDto.Password))] to both partial Map method overrides. This excludes sensitive or irrelevant properties from the generated mapping code.

Where should Mapperly mapper classes be placed in ASP.NET Zero?▼

Place all mappers for a feature in one file at Application/Mappers/{Feature}Mappers.cs using the flat CadentManagement.Mappers namespace. Group multiple mapper classes per feature file rather than one file per mapper.