{"record":{"id":"8171278b9ebd1cf9","repo":"dotnet/efcore","slug":"power-over-non-double-operands","errorCode":null,"errorMessage":"Power over non-double operands","messagePattern":"Power over non-double operands","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/LinqToCSharpSyntaxTranslator.cs","lineNumber":337,"sourceCode":"            case ExpressionType.OrAssign:\n                return VisitAssignment(binary, SyntaxKind.OrAssignmentExpression);\n            case ExpressionType.LeftShiftAssign:\n                return VisitAssignment(binary, SyntaxKind.LeftShiftAssignmentExpression);\n            case ExpressionType.RightShiftAssign:\n                return VisitAssignment(binary, SyntaxKind.RightShiftAssignmentExpression);\n            case ExpressionType.ExclusiveOrAssign:\n                return VisitAssignment(binary, SyntaxKind.ExclusiveOrAssignmentExpression);\n\n            case ExpressionType.Power when binary.Left.Type == typeof(double) && binary.Right.Type == typeof(double):\n                return Visit(\n                    Expression.Call(\n                        _mathPowMethod ??= typeof(Math).GetMethod(\n                            nameof(Math.Pow), BindingFlags.Static | BindingFlags.Public, [typeof(double), typeof(double)])!,\n                        binary.Left,\n                        binary.Right));\n\n            case ExpressionType.Power:\n                throw new NotImplementedException(\"Power over non-double operands\");\n\n            case ExpressionType.PowerAssign:\n                return Visit(\n                    Expression.Assign(\n                        binary.Left,\n                        Expression.Power(\n                            binary.Left,\n                            binary.Right)));\n        }\n\n        var liftedStatementOrigPosition = _liftedState.Statements.Count;\n        var left = Translate<ExpressionSyntax>(binary.Left);\n        var liftedStatementLeftPosition = _liftedState.Statements.Count;\n        var right = Translate<ExpressionSyntax>(binary.Right);\n\n        // If both sides were lifted, we don't need to do anything special. Same if the left side was lifted.\n        // But if the right side was lifted and the left wasn't, then in order to preserve evaluation order we need to lift the left side\n        // out as well, otherwise the right side gets evaluated before the left.","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/LinqToCSharpSyntaxTranslator.cs#L319-L355","documentation":"Thrown by VisitBinary for ExpressionType.Power when operands are not both double. Only double operands are supported (translated to a Math.Pow call); other numeric types are not auto-converted. Part of EF Core's LINQ-to-C# syntax translation.","triggerScenarios":"An expression tree containing Expression.Power (or PowerAssign) with non-double operand types such as int, float, or decimal.","commonSituations":"Building expression trees programmatically with Expression.Power over integers; query translators emitting Power with the wrong operand types.","solutions":["Cast both operands to double before constructing Expression.Power.","Use Math.Pow directly with double operands."],"exampleFix":"// before\nExpression.Power(leftInt, rightInt)\n// after\nExpression.Power(\n    Expression.Convert(leftInt, typeof(double)),\n    Expression.Convert(rightInt, typeof(double)))","handlingStrategy":"validation","validationCode":"// Validate Power operands are double before building the expression\nif (binary.NodeType == ExpressionType.Power\n    && (binary.Left.Type != typeof(double) || binary.Right.Type != typeof(double)))\n{\n    binary = Expression.Power(\n        Expression.Convert(binary.Left, typeof(double)),\n        Expression.Convert(binary.Right, typeof(double)));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always convert operands to double before Expression.Power.","In query translators, normalize numeric operands to double for exponentiation."],"tags":["efcore","expression-trees","math","power","type-mismatch"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}