Class SqlParameterCastExpression
Marks one usage of a SqlParameter as needing an explicit type in the generated SQL.
public sealed class SqlParameterCastExpression : SqlExpressionBase, ISqlExpression, IQueryElement, IEquatable<ISqlExpression>
- Inheritance
-
objectSqlParameterCastExpression
- Implements
- Inherited Members
- Extension Methods
Remarks
The need for a cast belongs to the position, not to the parameter: one instance is shared by every usage,
so a flag on it could only cast everywhere or nowhere. Wrapping the usage keeps a single parameter - a
single DECLARE - and casts only where the provider requires it.
This is deliberately not a SqlCastExpression. It carries no target type of its own: the
provider decides what to render (BasicSqlBuilder.GetParameterCastType), and several derive it from
the value bound for the current execution - the length of the actual string, the facets of the actual
decimal. Keeping it a separate node also means the code that reasons about real casts, such as the
set-operation type correlation in BasicSqlOptimizer, never mistakes this marker for a cast whose
type was chosen deliberately, and the cast folding in the optimizer cannot remove it.
Constructors
SqlParameterCastExpression(SqlParameter)
public SqlParameterCastExpression(SqlParameter parameter)
Parameters
parameterSqlParameter
Properties
ElementType
AST node type.
public override QueryElementType ElementType { get; }
Property Value
Parameter
public SqlParameter Parameter { get; }
Property Value
Precedence
public override int Precedence { get; }
Property Value
SystemType
public override Type SystemType { get; }
Property Value
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(SqlParameter)
public void Modify(SqlParameter parameter)
Parameters
parameterSqlParameter
ToString(QueryElementTextWriter)
Generates debug text representation of AST node.
public override QueryElementTextWriter ToString(QueryElementTextWriter writer)
Parameters
writerQueryElementTextWriter