private DbExpression ImplementEquality(DbExpression left, DbExpression right, EqualsPattern pattern)
{
switch (left.ExpressionKind)
{
case DbExpressionKind.Constant:
switch (right.ExpressionKind)
{
case DbExpressionKind.Constant: // constant EQ constant
return left.Equal(right);
case DbExpressionKind.Null: // null EQ constant --> false
return DbExpressionBuilder.False;
default:
return ImplementEqualityConstantAndUnknown((DbConstantExpression)left, right, pattern);
}
case DbExpressionKind.Null:
switch (right.ExpressionKind)
{
case DbExpressionKind.Constant: // null EQ constant --> false
return DbExpressionBuilder.False;
case DbExpressionKind.Null: // null EQ null --> true
return DbExpressionBuilder.True;
default: // null EQ right --> right IS NULL
return right.IsNull();
}
default: // unknown
switch (right.ExpressionKind)
{
case DbExpressionKind.Constant:
return ImplementEqualityConstantAndUnknown((DbConstantExpression)right, left, pattern);
case DbExpressionKind.Null: // left EQ null --> left IS NULL
return left.IsNull();
default:
return ImplementEqualityUnknownArguments(left, right, pattern);
}
}
}