SQL-250: PolicyExtensions.GenerateRelationshipPolicies¶
This statement is a create operation invoked through ORM (IRepository.Add). Executed by PolicyExtensions.GenerateRelationshipPolicies.
Classification¶
| Field | Value |
|---|---|
| SQL ID | SQL-250 |
| Operation type | Create |
| Execution method | ORM (IRepository.Add) |
| Database | Oracle* |
| Schema | [unqualified]** |
| Command type | N/A (ORM-generated) |
| Business object | PolicyExtensions |
| Criteria property | N/A — ORM |
| Lifecycle method | GenerateRelationshipPolicies |
Tables¶
| Table | Access | Columns used |
|---|---|---|
| POLICY | INSERT ×60 (hypothetical); UPDATE (self-reference, flush) | POLICY_NUM, POLICY_NAME, LEGAL_NAME, SECURE_POLICY_CODE, OFFICE_CODE, ACCOUNT_NUM, POLICY_STATUS_CODE, MARKET_TYPE_CODE, POLICY_RELATIONSHIP_POLICY_NUM, POLICY_RELATIONSHIP_CODE, customer_service_team_code, ENTITY_CODE, TRADING_SEQ_NUM, RATE_ACCOUNT, AGENT_NUM |
LINQ statement¶
Source: Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyExtensions.cs:127.
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyExtensions.cs:127-129
var polRepo = uow.GetRepository<Policy>();
var testRepo = polRepo as TestRepository<Policy>;
testRepo.KeyPropertyName = "PolicyNumber";
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyExtensions.cs:139-147
var policy = new Policy
{
MarketType = i.IsBetween(5, 10) ? arp : vol,
PolicyName = string.Concat(relationship.ToUpper(), " Parent Policy #", i),
Agent = saifAgent,
Relationship = rel
};
polRepo.Add(policy);
policy.RelationshipPolicy = policy;
// Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyExtensions.cs:150-158
var rPolicy = new Policy
{
MarketType = policy.MarketType,
PolicyName = string.Concat(relationship.ToUpper(), " Child Policy #", j),
Agent = saifAgent,
Relationship = rel,
RelationshipPolicy = policy
};
polRepo.Add(rPolicy);
Sample SQL¶
Test double — no runtime SQL. This statement executes against
TestUnitOfWork/TestRepository<T>(in-memory,List<TEntity>-backed test doubles inSAIF.Framework.Core); no NHibernate session is opened and no SQL is issued at runtime. The SQL below is the hypothetical statement the same expression would produce against a real NHibernateIUnitOfWorkusing the in-repo mappings, shown to document the mapping shape only — no database table is accessed when this code runs.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
INSERT INTO POLICY (
POLICY_NUM,
POLICY_NAME,
LEGAL_NAME,
SECURE_POLICY_CODE,
OFFICE_CODE,
ACCOUNT_NUM,
POLICY_STATUS_CODE,
MARKET_TYPE_CODE,
POLICY_RELATIONSHIP_POLICY_NUM,
POLICY_RELATIONSHIP_CODE,
customer_service_team_code,
ENTITY_CODE,
TRADING_SEQ_NUM,
RATE_ACCOUNT,
AGENT_NUM)
VALUES (
:PolicyNumber,
:PolicyName,
:LegalName,
:SecurePolicyCode,
:OfficeCode,
:AccountNumber,
:Status,
:MarketType,
:RelationshipPolicy,
:Relationship,
:CustomerServiceTeam,
:Entity,
:MainDbaName,
:RateAccount,
:Agent)
-- 10 parent + 50 child rows
-- line 147: policy.RelationshipPolicy = policy (set after Add) -> dirty at flush
UPDATE POLICY
SET POLICY_RELATIONSHIP_POLICY_NUM = :PolicyNumber
-- dynamic-update=false: all mapped columns are written
WHERE POLICY_NUM = :PolicyNumber
Translation notes:
- Not accessed: MARKET_TYPE_CODE, POLICY_RELATIONSHIP_CODE, Agent — FK values only (lookups are SQL-284/SQL-285).
- Same TestRepository<Policy> cast as SQL-249 (line 128) — not executable against a real UoW.
Sources¶
Data/SAIF.Data/TestRepository/RepositoryExtensions/PolicyExtensions.cs:127