---
title: "SQL-171: LocationQueryProvider.GetLocationContacts"
summary: Read operation for `LocationQueryProvider.GetLocationContacts`
status: draft
owner: SAIF.Core documentation team
last_reviewed: 2026-09-24
library: SAIF.Data
reference_type: package
---

# SQL-171: LocationQueryProvider.GetLocationContacts

This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by `LocationQueryProvider.GetLocationContacts`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-171 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `LocationQueryProvider` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `GetLocationContacts` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `locationId` | Input | long | N/A | Method argument of `LocationQueryProvider.GetLocationContacts` bound into the ORM expression; NHibernate generates the bind variable at runtime |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CONTACT](../database-tables.md#contact) | SELECT | LOC_SEQ_NUM, CONTACT_TYPE_CODE, CONTACT_EFF_DATE, CONTACT_EXP_DATE, BUS_SEQ_NUM, CONTACT_FIRST_NAME, CONTACT_INITIAL, CONTACT_LAST_NAME, CONTACT_TITLE, CONTACT_PHONE, CONTACT_PHONE_EXT, EMAIL_ADDR, CELL_PHONE, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Locations/LocationQueryProvider.cs:49-50`.

```csharp
public IQueryable<Contact> GetLocationContacts(long locationId)
{
    return Factory.GetRepository<Contact>()
        .Query().Where(x => x.Id == locationId && x.ExpirationDate == null).OrderBy(x => x.ContactType);
}
```

## Sample SQL

> **Inferred SQL:** This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.

```sql
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
SELECT
  C.LOC_SEQ_NUM,
  C.CONTACT_TYPE_CODE,
  C.CONTACT_EFF_DATE,
  C.CONTACT_EXP_DATE,
  C.BUS_SEQ_NUM,
  C.CONTACT_FIRST_NAME,
  C.CONTACT_INITIAL,
  C.CONTACT_LAST_NAME,
  C.CONTACT_TITLE,
  C.CONTACT_PHONE,
  C.CONTACT_PHONE_EXT,
  C.EMAIL_ADDR,
  C.CELL_PHONE,
  C.CREATE_USER,
  C.CREATE_DATE,
  C.UPDATE_USER,
  C.UPDATE_DATE
FROM CONTACT C
WHERE C.LOC_SEQ_NUM = :locationId
  AND C.CONTACT_EXP_DATE IS NULL
ORDER BY C.CONTACT_TYPE_CODE
```

Translation notes:
- `ContactMap` uses a composite key: `LOC_SEQ_NUM` (the `Id` property), `CONTACT_TYPE_CODE` (`ContactType`), and `CONTACT_EFF_DATE` (`EffectiveDate`).
- The method returns `IQueryable<Contact>`; execution is deferred to the caller.

## Operations and processes

- [Location lookups](../operations/location-lookups.md)

## Business rules

- [SD-BR-062 Location code and contact-type precedence](../business-rules.md#sd-br-062-location-code-and-contact-type-precedence)

## Sources
- `Data/SAIF.Data/Queries/Locations/LocationQueryProvider.cs:49`
