{
  "id": "dotnet/ef-core-query-compilation-failed",
  "signature": "Microsoft.EntityFrameworkCore.Query.QueryCompilationException: An exception occurred while compiling the query. See InnerException for details.",
  "signature_zh": "Microsoft.EntityFrameworkCore.Query.QueryCompilationException：编译查询时发生异常。请查看 InnerException 获取详细信息。",
  "regex": "Microsoft\\.EntityFrameworkCore\\.Query\\.QueryCompilationException: An exception occurred while compiling the query\\. See InnerException for details\\.",
  "domain": "dotnet",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "EF Core's query pipeline fails to translate a LINQ expression into SQL due to unsupported operations, such as custom method calls in Where clauses or complex client-side evaluation.",
  "root_cause_type": "generic",
  "root_cause_zh": "EF Core 的查询管道无法将 LINQ 表达式转换为 SQL，原因是支持的操作，例如 Where 子句中的自定义方法调用或复杂的客户端评估。",
  "versions": [
    {
      "version": "EF Core 6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EF Core 7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EF Core 8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This pulls the entire table into memory, causing performance issues and potential OutOfMemoryException.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This introduces SQL injection risks and loses the type safety of LINQ.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Rewrite the query to use only EF Core-supported functions. For example, replace 'Where(x => MyHelper.Calculate(x.Value) > 10)' with 'Where(x => x.Value > 10)' or use a computed column.",
      "success_rate": 0.85,
      "how": "Rewrite the query to use only EF Core-supported functions. For example, replace 'Where(x => MyHelper.Calculate(x.Value) > 10)' with 'Where(x => x.Value > 10)' or use a computed column.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use .ToList() before the unsupported operation and continue with LINQ to Objects: var list = context.Entities.Where(e => e.IsActive).ToList(); var result = list.Where(e => MyHelper.Calculate(e.Value) > 10);",
      "success_rate": 0.75,
      "how": "Use .ToList() before the unsupported operation and continue with LINQ to Objects: var list = context.Entities.Where(e => e.IsActive).ToList(); var result = list.Where(e => MyHelper.Calculate(e.Value) > 10);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "重写查询，仅使用 EF Core 支持的函数。例如，将 'Where(x => MyHelper.Calculate(x.Value) > 10)' 替换为 'Where(x => x.Value > 10)' 或使用计算列。",
    "在不支持的操作前使用 .ToList()，然后继续使用 LINQ to Objects：var list = context.Entities.Where(e => e.IsActive).ToList(); var result = list.Where(e => MyHelper.Calculate(e.Value) > 10);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/ef/core/querying/client-eval",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-04-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}