{"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/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/PrecompiledQueryCodeGenerator.cs#L701-L737","documentation":"Thrown in PrecompiledQueryCodeGenerator.GenerateInterceptorMethodSignature (line 719) when the operator symbol is a static method that is not an extension method. The interceptor generator only emits parameters for extension methods (this ...) and instance methods; a plain non-extension static method has no supported first-parameter shape, so it throws NotImplementedException. It marks an unsupported category of operator for the precompiled-query feature.","triggerScenarios":"Precompiling a query whose terminating/intermediate operator resolves to a static, non-extension method (e.g. a helper like Enumerable.Reverse used as a static call, or a custom static LINQ-like method that is not declared as an extension method). The switch over reducedOperatorSymbol in the parameter loop hits the default arm and throws.","commonSituations":"Calling LINQ-style helpers as static methods (Foo.Method(query, ...) rather than query.Method(...)) where Foo.Method is not an extension method. Using a custom static utility method in a query slated for precompilation. Provider extension methods that were not marked with 'this'.","solutions":["Replace the static non-extension call with an equivalent extension-method or instance-method form (e.g. call the operator as an extension so it appears as query.Operator(...)).","Remove the unsupported operator from the query being precompiled.","Exclude the query from precompiled-query generation.","If the method is yours, declare it as an extension method (this IQueryable<T> source, ...) so the interceptor can parameterize it."],"exampleFix":"// before: static non-extension helper used in a precompiled query\nvar q = MyQueryHelpers.Filter(db.Blogs, b => b.Active);\n\n// after: express as a standard extension/instance operator\nvar q = db.Blogs.Where(b => b.Active);","handlingStrategy":"validation","validationCode":"// Confirm the operator is an extension or instance method before generating\nvar m = operatorSymbol.OriginalDefinition;\nif (m.IsStatic && !m.IsExtensionMethod) { /* exclude query from precompilation */ }","typeGuard":"static bool IsSupportedOperatorKind(IMethodSymbol m)\n    => !m.IsStatic || m.IsExtensionMethod;","tryCatchPattern":"try { /* generate */ }\ncatch (NotImplementedException ex) when (ex.Message == \"Non-extension static method not supported\")\n{ /* exclude this query; restructure to use extension/instance form */ }","preventionTips":["Express LINQ helpers as extension methods or instance calls, not static non-extension calls.","Keep precompiled queries to standard operator invocation forms."],"tags":["ef-core","precompiled-query","extension-methods","code-generation","design-time"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}