# AutoMapper.Net4

**Kind:** Service

**Source:** `Pams/API/Pams.API/Pams.API.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`AutoMapper.Net4` is a NuGet package dependency declared by the `Pams.API` project. It supports object-to-object mapping in the API, such as converting domain models into request or response DTOs.

## Diagram

```mermaid
sequenceDiagram
    participant Client as TypeScript Client
    participant API as Pams.API
    participant Mapper as AutoMapper.Net4
    participant Model as Domain Model

    Client->>API: Send API request
    API->>Model: Read or create model data
    API->>Mapper: Map model to DTO
    Mapper-->>API: Return mapped DTO
    API-->>Client: Return JSON response
```

## Usage

```ts
type UserDto = {
  id: string;
  displayName: string;
};

async function getUser(id: string): Promise<UserDto> {
  const response = await fetch(`/api/users/${id}`);

  if (!response.ok) {
    throw new Error("Unable to load user");
  }

  return response.json();
}
```

## AI Coding Instructions

- Treat `AutoMapper.Net4` as a server-side dependency configured through `Pams.API.csproj`.
- Keep mapping configuration in the API layer where domain models are converted to DTOs.
- Do not expose domain entities directly from API endpoints when a mapped DTO is expected.
- Check existing mapping profiles before adding mappings for new request or response types.
