Table of Contents

Struct SqlIntervalType

Namespace
LinqToDB.Internal.SqlQuery
Assembly
linq2db.dll

Logical type of an interval expression: what it means, not how it is stored.

public readonly record struct SqlIntervalType : IEquatable<SqlIntervalType>
Implements
Inherited Members
Extension Methods

Remarks

Physical storage - a native INTERVAL, a BIGINT of ticks, a DECIMAL of seconds - is a separate concern, resolved from the mapping. Keeping the two apart is what lets the AST carry the intent through optimization and lower it per provider afterwards.

Constructors

SqlIntervalType(SqlIntervalDomain, SqlIntervalUnit, bool)

Logical type of an interval expression: what it means, not how it is stored.

public SqlIntervalType(SqlIntervalDomain Domain, SqlIntervalUnit Resolution, bool IsSigned)

Parameters

Domain SqlIntervalDomain

Whether the interval is a fixed duration or a calendar interval.

Resolution SqlIntervalUnit

Finest unit the interval can represent exactly. This is what makes precision loss computable: an operation whose exact result needs a finer unit than this cannot be translated and must be rejected rather than rounded.

IsSigned bool

Whether the interval can represent negative values.

Remarks

Physical storage - a native INTERVAL, a BIGINT of ticks, a DECIMAL of seconds - is a separate concern, resolved from the mapping. Keeping the two apart is what lets the AST carry the intent through optimization and lower it per provider afterwards.

Fields

ClrTimeSpan

The logical type of a CLR TimeSpan: a signed fixed-length duration with tick resolution.

public static readonly SqlIntervalType ClrTimeSpan

Field Value

SqlIntervalType

Properties

Domain

Whether the interval is a fixed duration or a calendar interval.

public SqlIntervalDomain Domain { get; init; }

Property Value

SqlIntervalDomain

IsSigned

Whether the interval can represent negative values.

public bool IsSigned { get; init; }

Property Value

bool

Resolution

Finest unit the interval can represent exactly. This is what makes precision loss computable: an operation whose exact result needs a finer unit than this cannot be translated and must be rejected rather than rounded.

public SqlIntervalUnit Resolution { get; init; }

Property Value

SqlIntervalUnit

Methods

ForDuration(DurationUnit, bool)

Returns the logical type of a duration stored in unit.

public static SqlIntervalType ForDuration(DurationUnit unit, bool isSigned = true)

Parameters

unit DurationUnit

Storage unit declared by the mapping.

isSigned bool

Whether the storage can hold negative values. Defaults to true.

Returns

SqlIntervalType

ToIntervalUnit(DurationUnit)

Maps a storage unit to the corresponding interval unit. Total by construction: DurationUnit deliberately has no calendar members.

public static SqlIntervalUnit ToIntervalUnit(DurationUnit unit)

Parameters

unit DurationUnit

Storage unit declared by the mapping.

Returns

SqlIntervalUnit