Class CaseExpression
- Namespace
- Microsoft.EntityFrameworkCore.Query.SqlExpressions
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
An expression that represents a CASE statement in a SQL tree.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
public class CaseExpression : SqlExpression, IPrintableExpression
- Inheritance
-
CaseExpression
- Implements
-
IPrintableExpression
- Inherited Members
Constructors
CaseExpression(SqlExpression, IReadOnlyList<CaseWhenClause>, SqlExpression)
Creates a new instance of the CaseExpression class which represents a simple CASE expression.
public CaseExpression(SqlExpression operand, IReadOnlyList<CaseWhenClause> whenClauses, SqlExpression elseResult = null)
Parameters
operand
SqlExpressionAn expression to compare with Test in WhenClauses.
whenClauses
IReadOnlyList<CaseWhenClause>A list of CaseWhenClause to compare and get result from.
elseResult
SqlExpressionA value to return if no WhenClauses matches, if any.
CaseExpression(IReadOnlyList<CaseWhenClause>, SqlExpression)
Creates a new instance of the CaseExpression class which represents a searched CASE expression.
public CaseExpression(IReadOnlyList<CaseWhenClause> whenClauses, SqlExpression elseResult = null)
Parameters
whenClauses
IReadOnlyList<CaseWhenClause>A list of CaseWhenClause to evaluate condition and get result from.
elseResult
SqlExpressionA value to return if no WhenClauses matches, if any.
Properties
ElseResult
The value to return if none of the WhenClauses matches.
public virtual SqlExpression ElseResult { get; }
Property Value
Operand
The value to compare in WhenClauses.
public virtual SqlExpression Operand { get; }
Property Value
WhenClauses
The list of CaseWhenClause to match Operand or evaluate condition to get result.
public virtual IReadOnlyList<CaseWhenClause> WhenClauses { get; }
Property Value
Methods
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
GetHashCode()
public override int GetHashCode()
Returns
Print(ExpressionPrinter)
protected override void Print(ExpressionPrinter expressionPrinter)
Parameters
expressionPrinter
ExpressionPrinter
Update(SqlExpression, IReadOnlyList<CaseWhenClause>, SqlExpression)
Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
public virtual CaseExpression Update(SqlExpression operand, IReadOnlyList<CaseWhenClause> whenClauses, SqlExpression elseResult)
Parameters
operand
SqlExpressionThe Operand property of the result.
whenClauses
IReadOnlyList<CaseWhenClause>The WhenClauses property of the result.
elseResult
SqlExpressionThe ElseResult property of the result.
Returns
- CaseExpression
This expression if no children changed, or an expression with the updated children.
VisitChildren(ExpressionVisitor)
protected override Expression VisitChildren(ExpressionVisitor visitor)
Parameters
visitor
ExpressionVisitor