private SqlExpression ApplyTypeMappingOnSqlBinary( SqlBinaryExpression sqlBinaryExpression, CoreTypeMapping?typeMapping) { var left = sqlBinaryExpression.Left; var right = sqlBinaryExpression.Right; Type resultType; CoreTypeMapping resultTypeMapping; CoreTypeMapping inferredTypeMapping; switch (sqlBinaryExpression.OperatorType) { case ExpressionType.Equal: case ExpressionType.GreaterThan: case ExpressionType.GreaterThanOrEqual: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.NotEqual: { inferredTypeMapping = ExpressionExtensions.InferTypeMapping(left, right) ?? _typeMappingSource.FindMapping(left.Type); resultType = typeof(bool); resultTypeMapping = _boolTypeMapping; } break; case ExpressionType.AndAlso: case ExpressionType.OrElse: { inferredTypeMapping = _boolTypeMapping; resultType = typeof(bool); resultTypeMapping = _boolTypeMapping; } break; case ExpressionType.Add: case ExpressionType.Subtract: case ExpressionType.Multiply: case ExpressionType.Divide: case ExpressionType.Modulo: case ExpressionType.LeftShift: case ExpressionType.RightShift: case ExpressionType.Coalesce: case ExpressionType.And: case ExpressionType.Or: { inferredTypeMapping = typeMapping ?? ExpressionExtensions.InferTypeMapping(left, right); resultType = left.Type; resultTypeMapping = inferredTypeMapping; } break; default: throw new InvalidOperationException("Incorrect operatorType for SqlBinaryExpression"); } return(new SqlBinaryExpression( sqlBinaryExpression.OperatorType, ApplyTypeMapping(left, inferredTypeMapping), ApplyTypeMapping(right, inferredTypeMapping), resultType, resultTypeMapping)); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> protected abstract Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression);
protected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression) { throw new NotImplementedException(); }