Table of Contents

Class DefaultColumnsProvider

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Default IColumnsProvider that tracks the column sources of a query in registration order and resolves lambda parameters to alias indexes within the current scope.

public class DefaultColumnsProvider : IColumnsProvider
Inheritance
DefaultColumnsProvider
Implements
Inherited Members
Extension Methods

Properties

HasAliases

Whether any column source has been registered.

public bool HasAliases { get; }

Property Value

bool

Methods

Add(QueryCommand, bool)

Registers a nested command as a source that contributes its projection columns.

public void Add(QueryCommand queryCommand, bool fromProjection)

Parameters

queryCommand QueryCommand

The source command.

fromProjection bool

Whether the source comes from a projection rather than a table.

Add(Type, bool)

Registers an entity type as a source that contributes columns.

public void Add(Type entityType, bool fromProjection)

Parameters

entityType Type

The CLR type of the source entity.

fromProjection bool

Whether the source comes from a projection rather than a table.

Add(Type, bool, ParameterExpression?)

Registers an entity type as a source bound to sourceParameter (#148-B R2.2). The parameter lets FindAlias(ParameterExpression, bool) resolve this source by occurrence identity, so two same-CLR-type joined sources stay distinct. The default implementation ignores the parameter and falls back to the type-keyed registration.

public void Add(Type entityType, bool fromProjection, ParameterExpression? sourceParameter)

Parameters

entityType Type

The CLR type of the source entity.

fromProjection bool

Whether the source comes from a projection rather than a table.

sourceParameter ParameterExpression

The lambda parameter that denotes the source, or null.

FindAlias(ParameterExpression, bool)

Resolves the alias index of param among the sources in the current scope. Returns null when the parameter does not map to a registered source.

public int? FindAlias(ParameterExpression param, bool fromProjection)

Parameters

param ParameterExpression

The lambda parameter to resolve.

fromProjection bool

Whether to match projection sources.

Returns

int?

FindAlias(ParameterExpression, bool, bool)

Resolves the alias of param. When includeOuterScopes is true the current source scope is ignored, so an enclosing command's source can be found (used for outer-reference markers).

public int? FindAlias(ParameterExpression param, bool fromProjection, bool includeOuterScopes)

Parameters

param ParameterExpression
fromProjection bool
includeOuterScopes bool

Returns

int?

FindAlias(ParameterExpression, bool, bool, bool)

Resolves the alias of param, also considering the sources of nested commands that already finished rendering when includeNestedSources is true; resolving a derived query's output columns needs that.

public int? FindAlias(ParameterExpression param, bool fromProjection, bool includeOuterScopes, bool includeNestedSources)

Parameters

param ParameterExpression

The lambda parameter to resolve.

fromProjection bool

Whether to match projection sources.

includeOuterScopes bool

Whether the current source scope is ignored (see the three-argument overload).

includeNestedSources bool

Whether sources of nested commands are considered too.

Returns

int?

FindAlias(Type, int?, bool)

Resolves the alias index of a source by entity type, optionally selecting the paramIdx-th same-typed source. Returns null when no matching source is in scope.

public int? FindAlias(Type entityType, int? paramIdx, bool fromProjection)

Parameters

entityType Type

The source entity type.

paramIdx int?

The zero-based index among same-typed sources, or null for the first.

fromProjection bool

Whether to match projection sources.

Returns

int?

FindAlias(Type, int?, bool, bool)

Like FindAlias(Type, int?, bool) but, when no source visible to the current command matches and includeNestedSources is true, falls back to a source of a nested command.

public int? FindAlias(Type entityType, int? paramIdx, bool fromProjection, bool includeNestedSources)

Parameters

entityType Type

The source entity type.

paramIdx int?

The zero-based index among same-typed sources, or null for the first.

fromProjection bool

Whether to match projection sources.

includeNestedSources bool

Whether sources of nested commands are considered too.

Returns

int?

FindInScopeQueryCommand(ParameterExpression, bool)

Returns the alias index and nested command of the in-scope source that param resolves to, or null when the parameter does not map to a source of the current scope. Unlike FindInScopeQueryCommand(Type) this uses the parameter's identity, so two same-typed sources in one command are told apart.

public (int Index, QueryCommand? Command)? FindInScopeQueryCommand(ParameterExpression param, bool fromProjection)

Parameters

param ParameterExpression

The lambda parameter whose source is resolved.

fromProjection bool

Whether to match projection sources.

Returns

(int Index, QueryCommand Command)?

FindInScopeQueryCommand(Type)

Returns the alias index and nested command of the source of entityType that belongs to the command currently being rendered, or null when that type is not a source of the current scope. Unlike FindQueryCommand(Type, bool) this never falls back to an out-of-scope source, so a derived-table reference is only resolved where the derived source is actually in scope.

public (int Index, QueryCommand? Command)? FindInScopeQueryCommand(Type entityType)

Parameters

entityType Type

The source entity type.

Returns

(int Index, QueryCommand Command)?

FindQueryCommand(Type)

Returns the alias index and nested command of the source of entityType, preferring an in-scope source and falling back to the most recently added out-of-scope one.

public (int, QueryCommand?) FindQueryCommand(Type entityType)

Parameters

entityType Type

The source entity type.

Returns

(int, QueryCommand)

FindQueryCommand(Type, bool)

Like FindQueryCommand(Type) but, when no source visible to the current command matches and includeNestedSources is true, falls back to a source of a nested command.

public (int, QueryCommand?) FindQueryCommand(Type entityType, bool includeNestedSources)

Parameters

entityType Type

The source entity type.

includeNestedSources bool

Whether sources of nested commands are considered too.

Returns

(int, QueryCommand)

PopScope()

Pops the most recently pushed parameter scope.

public void PopScope()

PopSourceScope()

Ends the scope opened by PushSourceScope(). Its entries remain addressable by index (aliases are assigned globally), but stop satisfying any enclosing command's lookups.

public void PopSourceScope()

PushScope(ReadOnlyCollection<ParameterExpression>)

Pushes a parameter scope that disambiguates same-typed sources from the enclosing scope.

public void PushScope(ReadOnlyCollection<ParameterExpression> parameters)

Parameters

parameters ReadOnlyCollection<ParameterExpression>

The lambda parameters that belong to the scope.

PushSourceScope()

Marks the source entries added from now on as belonging to the command currently being rendered, so that FindAlias(ParameterExpression, bool) of a nested command does not resolve to a same-typed source of an unrelated sibling command (or of the outer query).

public void PushSourceScope()