0
是否可以在Lambda中編寫等價的TSQL語句?c#Lambda子查詢(linq2sql)
SELECT DISTINCT pba1.adGroupsId , Amount = (SELECT pba2.value FROM ProjectBudgetAdjustment pba2 WHERE pba1.budgetId = pba2.budgetId AND pba1.adGroupsId = pba2.adGroupsId AND pba2.metricId IN ( SELECT id FROM Metrics WHERE [description] = 'Amount') ) , [Hours] = (SELECT pba2.value FROM ProjectBudgetAdjustment pba2 WHERE pba1.budgetId = pba2.budgetId AND pba1.adGroupsId = pba2.adGroupsId AND pba2.metricId IN ( SELECT id FROM Metrics WHERE [description] = 'Hours') ) FROM ProjectBudgetAdjustment pba1 WHERE pba1.budgetId IN ( SELECT id FROM ProjectBudget WHERE projectId IN ( SELECT id FROM Projects WHERE code = 'xxx' ) )
你爲什麼要重寫此查詢到LINQ到SQL/EF,不要忘記的可能性在你的查詢中表現鬆散。但從性能的角度來看,你應該重新設計你的查詢imho。只需將where子句重寫爲內連接。 – JSC 2011-02-10 15:23:02
使用linq2sql? linq over poco對象? – 2011-02-10 15:25:55