Struct SqlIntervalType
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
DomainSqlIntervalDomainWhether the interval is a fixed duration or a calendar interval.
ResolutionSqlIntervalUnitFinest 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.
IsSignedboolWhether 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
Properties
Domain
Whether the interval is a fixed duration or a calendar interval.
public SqlIntervalDomain Domain { get; init; }
Property Value
IsSigned
Whether the interval can represent negative values.
public bool IsSigned { get; init; }
Property Value
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
Methods
ForDuration(DurationUnit, bool)
Returns the logical type of a duration stored in unit.
public static SqlIntervalType ForDuration(DurationUnit unit, bool isSigned = true)
Parameters
unitDurationUnitStorage unit declared by the mapping.
isSignedboolWhether the storage can hold negative values. Defaults to true.
Returns
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
unitDurationUnitStorage unit declared by the mapping.