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

# SQL-151: ImageQueryProvider.AlertLegal

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

## Classification

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

## Parameters

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

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [LEGAL_CASE](../database-tables.md#legal_case) | SELECT | `CLAIM_ID`, `CLAIM_IMAGE_ALERTS_FLAG` |

## LINQ statement

Source: `Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:46`

```csharp
// Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:46
return Factory.GetRepository<LegalCase>().Query()
    .Count(x => x.ClaimId == claimId && x.IsImageAlert) > 0;
```

## 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 COUNT(*)
FROM LEGAL_CASE LC
WHERE LC.CLAIM_ID = :claimId
  AND LC.CLAIM_IMAGE_ALERTS_FLAG = 'Y'
```

Translation notes:
- `Count(pred) > 0`: the `> 0` comparison runs in memory on the returned count.
- `x.IsImageAlert` uses `YesNoType` (L22), so it becomes `= 'Y'`.
- The repository is obtained inline (`Factory.GetRepository<LegalCase>().Query()`).

## Operations and processes

- [Other query providers](../operations/other-query-providers.md)


## Sources
- `Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:46`
