{"record":{"id":"09ceb60a101718d1","repo":"dotnet/efcore","slug":"non-extension-static-method-not-supported","errorCode":null,"errorMessage":"Non-extension static method not supported","messagePattern":"Non-extension static method not supported","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/PrecompiledQueryCodeGenerator.cs","lineNumber":719,"sourceCode":"            for (var i = 0; i < reducedOperatorSymbol.Parameters.Length; i++)\n            {\n                var parameter = reducedOperatorSymbol.Parameters[i];\n\n                if (i == 0)\n                {\n                    switch (reducedOperatorSymbol)\n                    {\n                        case { IsExtensionMethod: true }:\n                            code.Append(\"this \");\n                            break;\n\n                        // For instance methods we already added a this parameter above\n                        case { IsStatic: false, ReceiverType: not null }:\n                            code.Append(\", \");\n                            break;\n\n                        default:\n                            throw new NotImplementedException(\"Non-extension static method not supported\");\n                    }\n                }\n                else\n                {\n                    code.Append(\", \");\n                }\n\n                code\n                    .Append(_g.TypeExpression(parameter.Type).ToFullString())\n                    .Append(' ')\n                    .Append(parameter.Name);\n            }\n\n            code.AppendLine(\")\");\n\n            foreach (var f in constraints)\n            {\n                code.AppendLine(f.NormalizeWhitespace().ToFullString());","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Design/Query/Internal/PrecompiledQueryCodeGenerator.cs#L701-L737","documentation":"Thrown while emitting the interceptor's first parameter when the reduced operator symbol is a static method that is neither an extension method nor an instance method. The generator handles 'this' extension parameters and instance-method receiver parameters, but a plain non-extension static method has no legal 'this'/'receiver' shape, so it throws NotImplementedException.","triggerScenarios":"A precompiled query chain includes a LINQ operator that resolves to a non-extension static method (i.e. not declared with a 'this' first parameter and not an instance method on the source).","commonSituations":"Calling helper/static utility methods that look like LINQ operators but are not extension methods; third-party query operators defined as plain static methods.","solutions":["Use only extension-method LINQ operators (declared with a 'this' first parameter) in precompiled queries.","Wrap the static helper as an extension method so the generator can treat its first parameter as the source.","Exclude that call from the precompiled-query path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure only extension-method or instance LINQ operators are used\n// For each operator in the chain, require reducedSymbol.IsExtensionMethod || (!reducedSymbol.IsStatic).","typeGuard":null,"tryCatchPattern":"try { generator.Generate(/*...*/); }\ncatch (NotImplementedException ex) when (ex.Message.Contains(\"Non-extension static method\"))\n{ /* replace the static helper with an extension method or exclude it */ }","preventionTips":["Define custom LINQ-like operators as extension methods (with a 'this' first parameter).","Avoid calling plain static utility methods inline in a precompiled query chain.","Document which operators are safe for precompiled queries."],"tags":["precompiled-queries","linq","extension-methods","interceptors"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}