{"record":{"id":"94fca48f1937cb41","repo":"dotnet/efcore","slug":"linq-query-comprehension-syntax-is-currently-not-s","errorCode":null,"errorMessage":"LINQ query comprehension syntax is currently not supported in precompiled queries.","messagePattern":"LINQ query comprehension syntax is currently not supported in precompiled queries\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs","lineNumber":990,"sourceCode":"            SyntaxKind.PostDecrementExpression => throw NotSupportedInExpressionTrees(),\n\n            _ => throw new UnreachableException(\n                $\"Unexpected syntax kind '{unary.Kind()}' when visiting a {nameof(PostfixUnaryExpressionSyntax)}\")\n        };\n\n        NotSupportedException NotSupportedInExpressionTrees()\n            => throw new UnreachableException(\n                $\"Unary expression of type {unary.Kind()} is not supported in expression trees\");\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public override Expression VisitQueryExpression(QueryExpressionSyntax node)\n        => throw new NotSupportedException(DesignStrings.QueryComprehensionSyntaxNotSupportedInPrecompiledQueries);\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public override Expression VisitSimpleLambdaExpression(SimpleLambdaExpressionSyntax lambda)\n        => VisitLambdaExpression(lambda);\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    public override Expression VisitTypeOfExpression(TypeOfExpressionSyntax typeOf)\n    {","sourceCodeStart":972,"sourceCodeEnd":1008,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Design/Query/Internal/CSharpToLinqTranslator.cs#L972-L1008","documentation":"VisitQueryExpression throws NotSupportedException for C# LINQ query comprehension syntax (from ... where ... select). Precompiled queries only support the method-based LINQ syntax that maps to expression-tree-building extension methods; query comprehension is an explicit, documented limitation.","triggerScenarios":"Writing a precompiled query using SQL-like query syntax: from b in ctx.Blogs where b.Active orderby b.Name select b.","commonSituations":"Developers who prefer SQL-like LINQ syntax or paste query-syntax examples into a precompiled query.","solutions":["Rewrite the query using method syntax with lambda expressions","Convert each clause: from/where -> .Where, orderby -> .OrderBy, select -> .Select"],"exampleFix":"// before\nfrom b in ctx.Blogs\nwhere b.Active\nselect b\n// after\nctx.Blogs.Where(b => b.Active)","handlingStrategy":"validation","validationCode":"// Detect query comprehension syntax in precompiled query source.\nstatic bool UsesQuerySyntax(string src)\n    => System.Text.RegularExpressions.Regex.IsMatch(src, @\"\\b(from|select|orderby|group\\s+by|join)\\b\");\nif (UsesQuerySyntax(querySource)) { /* rewrite to method syntax */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write precompiled queries in method syntax (.Where/.Select/.OrderBy)","Convert query-syntax examples before pasting them into a precompiled query","Enable an analyzer/roslynator rule to flag query syntax in precompiled query files"],"tags":["efcore","precompiled-queries","linq","query-syntax","csharp"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}