Table of Contents

Enum EagerLoadingStrategy

Namespace
LinqToDB
Assembly
linq2db.dll

Specifies the strategy used to execute eager loading (LoadWith/ThenLoad) preamble queries.

public enum EagerLoadingStrategy
Extension Methods

Fields

CteUnion = 2

CteUnion strategy: when two or more child associations at the same level use WithUnionLoadStrategy<T>(IQueryable<T>), their preamble queries are combined into a single UNION ALL query with a wide carrier tuple. This reduces round-trips (e.g., two children: 3 → 1 SELECT). Column slots are reused across branches when the nullable CLR type matches. Remaps to KeyedQuery when the current provider does not support CTEs; if the CteUnion batch cannot be formed (e.g., only one child association is present or the carrier exceeds MaxColumnCount) the whole strategy falls back through KeyedQuery and finally Default.

Default = 0

Default strategy: issues a pre-query using SELECT DISTINCT on the full parent entity joined to child rows via SelectMany. This is the existing behaviour.

KeyedQuery = 1

KeyedQuery strategy: the main query results are buffered, distinct parent keys are extracted client-side, and child records are loaded in a single batch query using WHERE key IN (...) or a VALUES table join. Useful when parent entities have many/wide columns, since the child preamble carries only keys rather than the full parent entity.