Instruction file imported from Petit-Pas/Blazor_DnD_FightTool (
.github/instructions/mapping.instructions.md). Copyright stays with the author.
Mapping Configuration Conventions (Mapster)
- Library: Mapster via custom
IMapper/Mapperwrapper in theMappinginfrastructure project. - Location: Each feature area has a
Mapping/MappingConfigurations.csfile next to the entities. - Visibility:
internal static class MappingConfigurationswithinternal static IServiceCollection Register{Feature}MappingConfigurations(...). - Config pattern: Use
TypeAdapterConfig<TSource, TTarget>.NewConfig()for custom mapping rules. - Duplication: Use
.IgnoreWhenDuplicating(x => x.Id)to skip identity properties duringClone()(but notCopy()). - Clone vs Copy:
Clone<T>()— creates a new instance with new Ids (for duplicating entities).Copy<T>()— creates an exact copy including Ids (for undo snapshots).
- Registration: Called from a parent
RegisterDnDEntitiesMappingConfigurations()extension method that chains all feature-specific registrations.