Class SqlIntervalPartExpression
A component or a total of an interval, expressed in a requested unit.
public sealed class SqlIntervalPartExpression : SqlExpressionBase, ISqlExpression, IQueryElement, IEquatable<ISqlExpression>
- Inheritance
-
objectSqlIntervalPartExpression
- Implements
- Inherited Members
- Extension Methods
Remarks
Component reproduces TimeSpan.Hours, truncating toward zero as CLR
integer division does; Total reproduces TimeSpan.TotalHours and keeps
the fraction. Provider division and modulo do not agree on negative values, so lowering must express the
truncation explicitly rather than lean on the database's own rules.
Constructors
SqlIntervalPartExpression(ISqlExpression, SqlIntervalUnit, SqlIntervalPartKind, DbDataType, SqlIntervalUnit?)
public SqlIntervalPartExpression(ISqlExpression interval, SqlIntervalUnit unit, SqlIntervalPartKind kind, DbDataType type, SqlIntervalUnit? within = null)
Parameters
intervalISqlExpressionunitSqlIntervalUnitkindSqlIntervalPartKindtypeDbDataTypewithinSqlIntervalUnit?
Properties
ElementType
AST node type.
public override QueryElementType ElementType { get; }
Property Value
Interval
Interval the part is taken from.
public ISqlExpression Interval { get; }
Property Value
Kind
Whether a component within an enclosing unit or the whole interval is requested.
public SqlIntervalPartKind Kind { get; }
Property Value
Precedence
public override int Precedence { get; }
Property Value
SystemType
public override Type? SystemType { get; }
Property Value
Type
public DbDataType Type { get; }
Property Value
Unit
Unit the result is expressed in.
public SqlIntervalUnit Unit { get; }
Property Value
Within
The unit a Component is counted within, or null when
it is not counted within anything - TimeSpan.Days is the whole day count and does not wrap.
Meaningless for Total.
public SqlIntervalUnit? Within { get; }
Property Value
Remarks
Stated rather than implied. "The next coarser unit" cannot express the two readings the same unit has -
TimeSpan.Microseconds counts within the millisecond while DATEPART(microsecond, ...)
counts within the second - and it is the enclosing unit, not this one, that decides whether a component
survives a coarse measurement: nanoseconds within a microsecond stay meaningful at tick resolution,
because a tick is a hundred of them.
Methods
Accept(QueryElementVisitor)
Visitor support.
public override IQueryElement Accept(QueryElementVisitor visitor)
Parameters
visitorQueryElementVisitor
Returns
CanBeNullable(NullabilityContext)
public override bool CanBeNullable(NullabilityContext nullability)
Parameters
nullabilityNullabilityContext
Returns
Equals(ISqlExpression, Func<ISqlExpression, ISqlExpression, bool>)
public override bool Equals(ISqlExpression other, Func<ISqlExpression, ISqlExpression, bool> comparer)
Parameters
otherISqlExpressioncomparerFunc<ISqlExpression, ISqlExpression, bool>
Returns
GetElementHashCode()
public override int GetElementHashCode()
Returns
Modify(ISqlExpression, SqlIntervalUnit, SqlIntervalPartKind, DbDataType, SqlIntervalUnit?)
public void Modify(ISqlExpression interval, SqlIntervalUnit unit, SqlIntervalPartKind kind, DbDataType type, SqlIntervalUnit? within)
Parameters
intervalISqlExpressionunitSqlIntervalUnitkindSqlIntervalPartKindtypeDbDataTypewithinSqlIntervalUnit?
ToString(QueryElementTextWriter)
Generates debug text representation of AST node.
public override QueryElementTextWriter ToString(QueryElementTextWriter writer)
Parameters
writerQueryElementTextWriter