SQL-148: ImageQueryProvider.GetAffilliatedImages¶
This statement is a read operation invoked through ORM (NHibernate LINQ). Executed by ImageQueryProvider.GetAffilliatedImages.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-148 |
| Operation type | Read |
| Execution method | ORM (NHibernate LINQ) |
| Database | Oracle* |
| Schema | Unknown** |
| Command type | N/A (ORM-generated) |
| Business object | ImageQueryProvider |
| Criteria property | N/A — ORM |
| Lifecycle method | GetAffilliatedImages |
Parameters¶
| Parameter | Direction | Type | Max length | Description |
|---|---|---|---|---|
:imageIds |
Input | List |
N/A | Built in memory: imageId plus each AffiliationImageId from the loaded affiliations. Contains becomes IN, and NHibernate expands the list into one bind per element |
Tables¶
| Table | Access | Columns used |
|---|---|---|
image** |
SELECT | unresolved (see Unresolved mapping) |
| IMAGE_AFFILIATION** | SELECT (lazy collection load, step 2; separate statement) | unresolved (see Unresolved mapping) |
LINQ statement¶
Source: Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:27. The repository is obtained at Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:15.
// Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:15
repository = Factory.GetRepository<Image>().Query();
// Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:25
var imageIds = new List<long> { imageId };
imageIds.AddRange(GetImage(imageId).ImageAffiliations.Select(item => item.AffiliationImageId));
return repository.Where(x => imageIds.Contains(x.Id)).ToList();
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.
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
-- Step 1 (L26): GetImage(imageId) runs SQL-147.
-- Step 2 (L26): lazy load of Image.ImageAffiliations (HasMany IMAGE_AFFILIATION); columns unresolved, so not written.
-- Step 3 (L27): the statement documented here
SELECT
<all mapped columns of Image> -- unresolved mapping: Image column list not documented
FROM image I
WHERE I.<Id column> IN (:imageIds) -- unresolved mapping: Image.Id
Translation notes:
- There are three round trips in total: SQL-147, the lazy collection initialization, then the IN query.
- With a large affiliation list, Oracle's 1000-element IN limit could be reached. NHibernate does not split the list automatically.
Operations and processes¶
Note: Statements marked with
**could not be confirmed; treat as unknown until verified.
Sources¶
Data/SAIF.Data/Queries/Policies/Images/ImageQueryProvider.cs:27