Table of Contents

Class AccessLibRedSqlExpressionConvertVisitor

Namespace
LinqToDB.Internal.DataProvider.Access
Assembly
linq2db.dll
public class AccessLibRedSqlExpressionConvertVisitor : AccessSqlExpressionConvertVisitor
Inheritance
object
AccessLibRedSqlExpressionConvertVisitor
Inherited Members
Extension Methods

Constructors

AccessLibRedSqlExpressionConvertVisitor(bool)

public AccessLibRedSqlExpressionConvertVisitor(bool allowModify)

Parameters

allowModify bool

Properties

CanLowerIntervalDifference

Whether an elapsed date difference can be lowered to a value here.

public override bool CanLowerIntervalDifference { get; }

Property Value

bool

Remarks

Declared beside the lowering it describes, and read by the member translator through ITranslationContext.ProviderFlags. The translator has to ask before it builds anything, because a difference it does not build stays an ordinary .NET subtraction and is computed on materialisation - and by the time this visitor runs, the read expression is already bound to its columns, so there is no going back.

CanLowerIntervalShift

Whether LowerTemporalArithmetic(SqlTemporalArithmeticExpression) can express a date shifted by an interval at all.

public override bool CanLowerIntervalShift { get; }

Property Value

bool

Remarks

Read by the member translator so a declared duration added to a date is declined while the expression is still being built, rather than reaching the builder as a node nothing can render - a refusal there has no client-side fallback left. The default follows what the base implementation needs: it spends the amount through ShiftDate(SqlIntervalUnit, ISqlExpression, ISqlExpression) at FinestDateUnit, so a provider that names no finest unit cannot lower one.

Only the declared half is declined early. A shift by a computed difference is left to be built, because start + (end - start) cancels against the difference it came from and asks the provider for nothing - refusing it here would sink a query that works everywhere.

CanMeasureDifferenceInTicks

And no tick count either, for the reason ElapsedTicks(SqlIntervalDifferenceExpression) gives, which is what leaves a total below the resolution with nowhere to come from rather than merely quantised.

public override bool CanMeasureDifferenceInTicks { get; }

Property Value

bool

CanNegateSortKeyUnderDistinct

Whether the engine accepts a negated boolean sort key under DISTINCT, so a nullable key keeps NULL first there too. Jet and ACE reject it as conflicting with DISTINCT.

protected override bool CanNegateSortKeyUnderDistinct { get; }

Property Value

bool

FinestDateUnit

A second is as fine as Access counts - DateDiff has no millisecond part at all.

protected override SqlIntervalUnit? FinestDateUnit { get; }

Property Value

SqlIntervalUnit?

Remarks

The whole-unit members are still exact, because the anchor correction compares actual dates rather than trusting the count. What this limits is the fraction of a Total and anything below a second, which an OLE Automation date - a floating day number - could not carry reliably anyway.

IntervalResolution

A second is also as fine as the measurement resolves, so a component asked for below one is identically zero rather than merely imprecise.

public override SqlIntervalUnit IntervalResolution { get; }

Property Value

SqlIntervalUnit

Remarks

Access refuses such a member either way - there is no millisecond date part to extract and no tick count to divide - but where it refuses decides what a caller can do about it. Declined here, while the expression is still being built, the message names the unit and the resolution, and a projection stays free to fall back to .NET, which holds both dates and answers exactly. Left to the builder, the refusal arrives as an exception with no such escape.

IsTickArithmeticSupported

Whether this engine can count and shift in a unit fine enough, and wide enough, to carry a tick count - which Jet and ACE cannot, for the reasons ElapsedTicks(SqlIntervalDifferenceExpression) and LowerTemporalArithmetic(SqlTemporalArithmeticExpression) give.

protected override bool IsTickArithmeticSupported { get; }

Property Value

bool

Methods

CountDateBoundaries(SqlIntervalUnit, ISqlExpression, ISqlExpression)

Boundary counting through DateDiff, whose count is a 32-bit value - so a count in seconds is taken across the sub-day remainder rather than across the whole span.

protected override ISqlExpression? CountDateBoundaries(SqlIntervalUnit unit, ISqlExpression start, ISqlExpression end)

Parameters

unit SqlIntervalUnit
start ISqlExpression
end ISqlExpression

Returns

ISqlExpression

Remarks

A second count reaches the 32-bit limit after about sixty-eight years, which is inside the range a person's age can reach. Past it Access answers Numeric value out of range instead of a number, and it does so before any cast here can widen the result - the overflow happens while Access computes the count. Counting days first and seconds only from there keeps both counts small: days stay 32-bit for any date Access can hold, and the remainder spans at most a day. Every coarser datepart is counted directly, being far from the limit - minutes reach it only after four thousand years.

The two counts telescope, so the split is exact rather than an approximation. DateDiff truncates both operands to the unit and subtracts, which makes it additive through any intermediate point, and shifting by whole days leaves the time of day alone - so the day count contributes exactly its own seconds. That holds even when the day count overshoots the end, as it does between an evening and the following morning: the remainder comes back negative by the same amount.

CDbl is what keeps the product from overflowing in turn - Access multiplies in 32-bit integers and a century of days is past that once scaled to seconds. A cast to a wider integer would not do: Access has none to name, and a cast to a floating type renders as nothing here.

Neither operand is ever null here: LowerIntervalPart(SqlIntervalPartExpression) replaces one that can be before counting starts.

This provider is the only one that gets here - it is the only override of ElapsedTicksResolveMembers to false, and everywhere else a member is taken from the tick count instead.

DatePartName(SqlIntervalUnit)

protected override string? DatePartName(SqlIntervalUnit unit)

Parameters

unit SqlIntervalUnit

Returns

string

EscapeLikeCharacters(ISqlExpression, ref ISqlExpression?)

public override ISqlExpression EscapeLikeCharacters(ISqlExpression expression, ref ISqlExpression? escape)

Parameters

expression ISqlExpression
escape ISqlExpression

Returns

ISqlExpression