Skip to content

AutoMapper.Net4

reference
1 min readUpdated

Kind: Service

Source: Pams/Logic/Pams.Business/Pams.Business.csproj (line 1)

Part of: Pams

NuGet package dependency

AutoMapper.Net4 is a NuGet package dependency declared in Pams.Business.csproj. The Pams.Business project uses it to map data between source models, business models, and transfer models without manual property-by-property assignment.

Diagram

mermaid
sequenceDiagram
    participant Caller
    participant Business as Pams.Business
    participant Mapper as AutoMapper.Net4
    participant Model as Target Model

    Caller->>Business: Request mapped data
    Business->>Mapper: Map(source)
    Mapper->>Model: Create and populate target
    Model-->>Business: Mapped instance
    Business-->>Caller: Return mapped data

Usage

ts
type CustomerDto = {
  id: string;
  name: string;
};

async function getCustomer(id: string): Promise<CustomerDto> {
  const response = await fetch(`/api/customers/${encodeURIComponent(id)}`);

  if (!response.ok) {
    throw new Error("Customer request failed");
  }

  // The Pams.Business API maps its internal model to CustomerDto
  // through AutoMapper.Net4 before returning this response.
  return response.json();
}

const customer = await getCustomer("customer-id");
console.log(customer.name);

AI Coding Instructions

  • Keep AutoMapper profile and mapping configuration in the Pams.Business layer or its related configuration code.
  • Add explicit mappings when source and target property names differ or require conversion.
  • Check mappings when changing DTOs, domain models, or data-access entities.
  • Do not expose persistence entities directly from API or business-layer boundaries; map them to the intended contract model.

Used by

2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Injected or called by (2)

  • Pams.APIPams/API/Pams.API/Pams.API.csproj:1
  • Pams.BusinessPams/Logic/Pams.Business/Pams.Business.csproj:1

Was this page helpful?

Download as PDF