Complex Lambda to SQL

本文关键字:SQL to Lambda Complex | 更新日期: 2023-09-27 18:33:31

我有一个 Lambda 表达式,它导致"序列中的多个值",即数据重复。这是 lambda 表达式:

var destinations = this.contentBusiness.GetAllDisplayVersions()
.Where(x => airportDestinations.Any(y => y.DestinationAirport.DestinationGuideId == x.ParentId))
.Select(x => new DestinationViewModel(airportDestinations.Single(y => y.DestinationAirport.DestinationGuideId == x.ParentId), x));

现在我需要相应的 SQL 语句

Complex Lambda to SQL

为什么不运行 SQL 事件探查器?

  • 在此行上放置一个断点。
  • 在下一行放置目的地。AsEnumerable() 强制运行 SQL。
  • 运行应用程序。
  • 当断点命中时,运行启动探查器跟踪
  • 运行到 AsEnumerable() 或等效行(即将强制生成 SQL 并针对 SQL Server 运行的行)
  • 查看 SQL 事件探查器选取了哪些内容。