Table of Contents

Class SqlServerSqlExpressionConvertVisitor

Namespace
LinqToDB.Internal.DataProvider.SqlServer
Assembly
linq2db.dll
public class SqlServerSqlExpressionConvertVisitor : SqlExpressionConvertVisitor
Inheritance
object
SqlServerSqlExpressionConvertVisitor
Derived
Inherited Members
Extension Methods

Constructors

SqlServerSqlExpressionConvertVisitor(bool, SqlServerVersion)

public SqlServerSqlExpressionConvertVisitor(bool allowModify, SqlServerVersion sqlServerVersion)

Parameters

allowModify bool
sqlServerVersion SqlServerVersion

Properties

CanLowerIntervalDifference

DATEDIFF_BIG arrived in 2016; earlier versions leave date subtraction to .NET.

public override bool CanLowerIntervalDifference { get; }

Property Value

bool

FinestDateUnit

DATEDIFF_BIG counts nanoseconds, and datetime2 stores 100ns, so the leftover of a total is exact. It is only ever applied to a sub-unit window, well inside the roughly 292 years at which the nanosecond form would overflow.

protected override SqlIntervalUnit? FinestDateUnit { get; }

Property Value

SqlIntervalUnit?

Remarks

The nanosecond datepart arrived with datetime2 in 2008 - DATEADD on 2005 answers is not a recognized dateadd option - so that version counts in milliseconds instead, which is as fine as its own datetime resolves anyway. Version-checked here rather than overridden on the 2005 visitor, because the 2008 one derives from it and would inherit the wrong answer.

SupportsDistinctAsExistsIntersect

protected override bool SupportsDistinctAsExistsIntersect { get; }

Property Value

bool

Methods

ConvertConcat(SqlConcatExpression)

public override ISqlExpression ConvertConcat(SqlConcatExpression element)

Parameters

element SqlConcatExpression

Returns

ISqlExpression

ConvertConversion(SqlCastExpression)

Implements SqlCastExpression conversion.

protected override ISqlExpression ConvertConversion(SqlCastExpression cast)

Parameters

cast SqlCastExpression

Returns

ISqlExpression

ConvertSearchStringPredicate(SearchString)

public override ISqlPredicate ConvertSearchStringPredicate(SqlPredicate.SearchString predicate)

Parameters

predicate SqlPredicate.SearchString

Returns

ISqlPredicate

ConvertSqlBinaryExpression(SqlBinaryExpression)

public override IQueryElement ConvertSqlBinaryExpression(SqlBinaryExpression element)

Parameters

element SqlBinaryExpression

Returns

IQueryElement

ConvertSqlFunction(SqlFunction)

public override ISqlExpression ConvertSqlFunction(SqlFunction func)

Parameters

func SqlFunction

Returns

ISqlExpression

CountDateBoundaries(SqlIntervalUnit, ISqlExpression, ISqlExpression)

Counts unit boundaries crossed between two date/time values - the provider's DATEDIFF.

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

Parameters

unit SqlIntervalUnit
start ISqlExpression
end ISqlExpression

Returns

ISqlExpression

Remarks

Boundary counting, not elapsed time. It is deliberately the wrong answer on its own: it is the cheap starting estimate that the anchor correction turns into the elapsed count, and being a count of whole units it cannot overflow the way a fine-grained difference over the same range would.

IsWindowOrderByRequired(SqlExtendedFunction)

Every ranking function and every one that reads a neighbouring row - The function 'ROW_NUMBER' must have an OVER clause with ORDER BY - and any frame at all, which is Incorrect syntax near 'ROWS' without one. An unframed aggregate is exempt: SUM(x) OVER () is valid.

protected override bool IsWindowOrderByRequired(SqlExtendedFunction func)

Parameters

func SqlExtendedFunction

Returns

bool

ShiftDate(SqlIntervalUnit, ISqlExpression, ISqlExpression)

Shifts a date/time value by a whole number of units - the provider's DATEADD.

protected override ISqlExpression? ShiftDate(SqlIntervalUnit unit, ISqlExpression amount, ISqlExpression date)

Parameters

unit SqlIntervalUnit
amount ISqlExpression
date ISqlExpression

Returns

ISqlExpression

Remarks

Must be exact: the anchor correction in IntervalLowering shifts by a computed count and compares the result against the original, so an approximate shift would produce an off-by-one count.

WrapColumnExpression(ISqlExpression)

protected override ISqlExpression WrapColumnExpression(ISqlExpression expr)

Parameters

expr ISqlExpression

Returns

ISqlExpression