Class SqlServerSqlExpressionConvertVisitor
- Namespace
- LinqToDB.Internal.DataProvider.SqlServer
- Assembly
- linq2db.dll
public class SqlServerSqlExpressionConvertVisitor : SqlExpressionConvertVisitor
- Inheritance
-
objectSqlServerSqlExpressionConvertVisitor
- Derived
- Inherited Members
- Extension Methods
Constructors
SqlServerSqlExpressionConvertVisitor(bool, SqlServerVersion)
public SqlServerSqlExpressionConvertVisitor(bool allowModify, SqlServerVersion sqlServerVersion)
Parameters
allowModifyboolsqlServerVersionSqlServerVersion
Properties
CanLowerIntervalDifference
DATEDIFF_BIG arrived in 2016; earlier versions leave date subtraction to .NET.
public override bool CanLowerIntervalDifference { get; }
Property Value
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
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
Methods
ConvertConcat(SqlConcatExpression)
public override ISqlExpression ConvertConcat(SqlConcatExpression element)
Parameters
elementSqlConcatExpression
Returns
ConvertConversion(SqlCastExpression)
Implements SqlCastExpression conversion.
protected override ISqlExpression ConvertConversion(SqlCastExpression cast)
Parameters
castSqlCastExpression
Returns
ConvertSearchStringPredicate(SearchString)
public override ISqlPredicate ConvertSearchStringPredicate(SqlPredicate.SearchString predicate)
Parameters
predicateSqlPredicate.SearchString
Returns
ConvertSqlBinaryExpression(SqlBinaryExpression)
public override IQueryElement ConvertSqlBinaryExpression(SqlBinaryExpression element)
Parameters
elementSqlBinaryExpression
Returns
ConvertSqlFunction(SqlFunction)
public override ISqlExpression ConvertSqlFunction(SqlFunction func)
Parameters
funcSqlFunction
Returns
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
unitSqlIntervalUnitstartISqlExpressionendISqlExpression
Returns
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
funcSqlExtendedFunction
Returns
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
unitSqlIntervalUnitamountISqlExpressiondateISqlExpression
Returns
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
exprISqlExpression