{"record":{"id":"ec63468a4b5652cd","repo":"dotnet/efcore","slug":"named-argument","errorCode":null,"errorMessage":"Named argument","messagePattern":"Named argument","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":717,"sourceCode":"                destArguments[paramIndex] = Constant(\n                    parameter.DefaultValue is null && parameter.ParameterType.IsValueType\n                        ? Activator.CreateInstance(parameter.ParameterType)\n                        : parameter.DefaultValue,\n                    parameter.ParameterType);\n                continue;\n            }\n\n            var argument = invocation.ArgumentList.Arguments[sourceArgIndex++];\n\n            // Positional argument\n            if (argument.NameColon is null)\n            {\n                destArguments[paramIndex] = Visit(argument, parameter.ParameterType);\n                continue;\n            }\n\n            // Named argument\n            throw new NotImplementedException(\"Named argument\");\n        }\n\n        Check.DebugAssert(destArguments.All(a => a is not null), \"arguments.All(a => a is not null)\");\n\n        return Call(instance, methodInfo, destArguments!);\n\n        IEnumerable<KeyValuePair<string, Type>> GetTypeTypeParameters(INamedTypeSymbol typeSymbol)\n        {\n            // TODO: We match Roslyn type parameters by name, not sure that's right; also for the method's generic type parameters\n\n            if (typeSymbol.ContainingType is { } containingTypeSymbol)\n            {\n                foreach (var kvp in GetTypeTypeParameters(containingTypeSymbol))\n                {\n                    yield return kvp;\n                }\n            }\n","sourceCodeStart":699,"sourceCodeEnd":735,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L699-L735","documentation":"Thrown as NotImplementedException when a method invocation argument uses named argument syntax (e.g. Foo(name: value)). The translator's argument-binding loop handles positional arguments, optional parameters, and params arrays, but explicitly throws when it encounters an argument with NameColon set. Named argument binding is an unimplemented feature in the translator.","triggerScenarios":"A precompiled query contains a method call with named arguments: `ctx.Blogs.Where(b => SomeHelper(predicate: b.Id > 5, threshold: 10))`, or any LINQ/operator call where the developer used `paramName:` syntax. The translator encounters `argument.NameColon != null` and throws.","commonSituations":"Developers who use named arguments for readability in complex LINQ calls; code generated by tools/analyzers that favor named arguments; queries that call methods with many optional parameters where named arguments clarify intent; ReSharper/IDE refactoring that converts positional args to named args.","solutions":["Rewrite the method call to use positional arguments only: remove all `paramName:` prefixes and order arguments to match the method signature.","If the method has many optional parameters, provide all preceding arguments positionally up to the one you need, passing defaults or explicit values for the ones in between.","Disable IDE auto-formatting rules that insert named arguments (e.g. 'Use named arguments' code style) for files containing precompiled queries.","If a third-party source generator produces named arguments, configure it to emit positional arguments for precompiled query code."],"exampleFix":"// before\nvar query = ctx.Blogs.Where(b => Validate(id: b.Id, mode: CheckMode.Strict));\n\n// after\nvar query = ctx.Blogs.Where(b => Validate(b.Id, CheckMode.Strict));","handlingStrategy":"validation","validationCode":"// Before precompiling, scan for named arguments in method invocations\nvar namedArgs = querySyntaxTree.DescendantNodes()\n    .OfType<InvocationExpressionSyntax>()\n    .SelectMany(i => i.ArgumentList?.Arguments ?? new SeparatedSyntaxList<ArgumentSyntax>())\n    .Where(a => a.NameColon is not null);\nif (namedArgs.Any())\n    ReportError(\"Named arguments are not supported in precompiled queries — use positional arguments\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use named argument syntax (paramName:) in methods called inside precompiled query lambdas.","Disable the 'Use named arguments' IDE code style in .editorconfig for files with precompiled queries.","Configure source generators and refactoring tools to emit positional arguments.","Review auto-generated query code for named arguments before enabling precompilation."],"tags":["precompiled-queries","roslyn","method-invocation","named-arguments","not-implemented","csharp-syntax"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}