---
title: "SQL-018: MCO location lookup (McoLocation)"
summary: Reads the claim's assigned MCO location by the Guidewire MCO identifier.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-018: MCO location lookup (McoLocation)

The `Claim.Mco` read-model property queries `McoLocation` by the Guidewire MCO identifier and returns the first match, exposing the claim's assigned MCO location. This is an ORM operation, not raw SQL — NHibernate generates the actual query at runtime from the `McoLocation` ClassMap.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-018 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A — ORM (NHibernate generates SQL at runtime from the ClassMaps in `Data/SAIF.Data.NHibernate/Mappings/**`) |
| **Business object** | `Claim` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `Mco` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [MCO_GSA_LOCATION](../database-tables.md#mco_gsa_location) | SELECT | `MCO_ID`, `EFF_DATE`, `EXP_DATE`, `LOCATION_NAME`, `UPDATE_DATE`, `UPDATE_USER`, `UPDATE_NUM`, `MCO_PLAN_ID` |

## LINQ statement

Source: `Domain/SAIF.Domain/Model/Claims/Claim.cs:104`

```csharp
// Domain/SAIF.Domain/Model/Claims/Claim.cs:104-105
var mco = Factory.GetRepository<ClaimModel.McoLocation>().Query()
        .Where(x => x.Id == gwMco.mcoID).FirstOrDefault();
```

## 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 *
FROM (
  SELECT
    MGL.MCO_ID,
    MGL.EFF_DATE,
    MGL.EXP_DATE,
    MGL.LOCATION_NAME,
    MGL.UPDATE_DATE,
    MGL.UPDATE_USER,
    MGL.UPDATE_NUM,
    MGL.MCO_PLAN_ID
  FROM MCO_GSA_LOCATION MGL
  WHERE MGL.MCO_ID = :mcoID
)
WHERE ROWNUM <= 1
```

Translation notes:
- `x.Id` is the identifier, mapped to `MCO_ID` (`MCOLocationMap.cs:14-15`) — the prior page's column `ID` is incorrect.
- `FirstOrDefault()` on `OracleDataClientConfiguration.Oracle10` (Legends: SAIF.Framework.Data.NHibernate `OracleConfigurationFactory`) → `ROWNUM` wrapper; the limit is shown as the literal `1`.
- `UPDATE_NUM` is mapped with `Map` (not `Version`) on this entity, so it is an ordinary selected column.
- Assignments to `mco.ClaimEligibilityStatus` (lines 106-109) are in memory (unmapped property); the Guidewire API calls (lines 100-102) are HTTP, not SQL.
- `References(x => x.Plan)` loads lazily; `MCO_PLAN_ID` is selected but the plan table is not joined.

## Operations and processes
- OP-DOM-18 Claim read model — loads Guidewire-derived data on demand and exposes derived claim properties (see [Operations and processes](../operations-processes.md))

## Business rules
No business rule directly enforced by this statement.

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- Domain/SAIF.Domain/Model/Claims/Claim.cs
