我用
`.....
.....
query = query.Where(criterion, fiedNames);
string sql2 = ((ObjectQuery)query).ToTraceString();'
获取和调整将由 LINQ 执行的 SQL 代码。
当我快速观看时,我得到以下我不理解的 SQL 语句。
SELECT [UnionAll2].[C3] AS [C1], [UnionAll2].[C4] AS [C2],
[UnionAll2].[C5] AS [C3], [UnionAll2].[C6] AS [C4],
[UnionAll2].[C7] AS [C5],
[UnionAll2].[C8] AS [C6],
[UnionAll2].[C9] AS [C7],
..... few hundereds line more.....
@p__linq__4 AS [C2],
.....
CASE
WHEN ( [Join5].[id] IS NULL ) THEN
Cast(NULL AS INT)
WHEN ( @p__linq__0 = 1 )
.......
显然,如果我粘贴到 SQL 管理工作室并执行它,如果我没有传递 ... 的值,它会抛出错误@p__linq__0
。
我的问题:如何获取可以在 SQL 管理上执行的跟踪 SQL?