# PamsLinqDataContext

**Kind:** Class

**Source:** `Pams/Data/Pams.Data/PamsLinq5.designer.cs` (line 26)

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

`PamsLinqDataContext` is a LINQ to SQL data context generated in `Pams/Data/Pams.Data/PamsLinq5.designer.cs`. It exposes table mappings for lookup and audit entities, allowing application code to query and persist records such as currencies, document types, nationalities, and database logs.

## Diagram

```mermaid
graph LR
  Context[PamsLinqDataContext]

  Context --> Currencies[Currency]
  Context --> DBLogs[DBLog]
  Context --> DBLogUsers[DBLogUser]
  Context --> DocumentTypes[DocumentType]
  Context --> EmailAddressTypes[EmailAddressType]
  Context --> Genders[Gender]
  Context --> Nationalities[Nationality]
  Context --> PhoneNumberTypes[PhoneNumberType]
  Context --> ReasonTypes[ReasonType]
  Context --> SerialTypes[SerialType]
```

## Usage

```ts
type Currency = {
  id: string;
  code: string;
  name: string;
};

async function loadCurrencies(): Promise<Currency[]> {
  const response = await fetch("/api/lookups/currencies");

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

  return response.json();
}

const currencies = await loadCurrencies();
console.log(currencies.map((currency) => currency.code));
```

## AI Coding Instructions

- Treat `PamsLinqDataContext` as the database boundary for LINQ to SQL queries and updates.
- Query lookup tables such as `Currencies`, `Genders`, and `Nationalities` through their mapped `Table<T>` members.
- Keep changes to `PamsLinq5.designer.cs` limited; regenerate the designer file when the database mapping changes.
- Submit pending inserts, updates, and deletes through the data context's change submission flow.
- Avoid exposing LINQ entity types directly to JavaScript clients; map them to API response models.

## Relationships

- IMPORTS → `Comment`
- IMPORTS → `Status`

## Used by

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

### Imported by (353)

- `FilesController` — `Pams/API/Pams.API/Controllers/Common/FilesController.cs`:27
- `UnitOfWork` — `Pams/Logic/Pams.Business/Component/UnitOfWork.cs`:12
- `EndUser` — `Pams/Logic/Pams.Business/Domain/Import/ImportDomain.cs`:3891
- `AccountManagerTarget` — `Pams/Logic/Pams.Business/Entity/BookingTarget/AccountManagerTarget.cs`:7
- `ForecastedBookingRule` — `Pams/Logic/Pams.Business/Entity/BookingTarget/ForecastedBookingRule.cs`:7
- `MonthlyBacklog` — `Pams/Logic/Pams.Business/Entity/BookingTarget/MonthlyBacklog.cs`:7
- `MonthlyForecast` — `Pams/Logic/Pams.Business/Entity/BookingTarget/MonthlyForecast.cs`:7
- `MonthlyProductTypeBacklog` — `Pams/Logic/Pams.Business/Entity/BookingTarget/MonthlyProductTypeBacklog.cs`:7

…and 345 more.
