-1
我想加入基於ID
列兩個表上Table2
是在像列ID
Table1
Ef6點符號;與條件colums加入喜歡,不等於
me.dbSet.Join(me.context.Table2, p => p.ID, e => e.ID,
(p, e) => new { p, e }).Where(z => z.e.ID== uid)
的SQL輸出:
SELECT
1 AS [C1]
FROM [NG].[T1] AS [Extent1]
INNER JOIN [NG].[T2] AS [Extent2] ON [Extent1].[ID] = [Extent2].[ID]
WHERE [Extent2].[ID] = 'f520f7b3-215d-4dfe-9787-1eb6864fb335'
我試圖用linq寫的sql:
SELECT
1 AS [C1]
FROM [NG].[T1] AS [Extent1]
INNER JOIN [NG].[T2] AS [Extent2] ON [Extent1].[ID] Like [Extent2].[ID] + '%'
WHERE [Extent2].[ID] = 'f520f7b3-215d-4dfe-9787-1eb6864fb335'
是更多鈔票來用點表示寫這 – semirturgay
檢查編輯,未經測試,但應該工作 – DavidG
首先爲您解答所有thaks的它的工作原理,但它是在很慢?。與'table1.id +'%''加入table1.id相比因爲它加入了'on 1 = 1'表,然後過濾記錄。我正在用一個擁有超過100萬條記錄的大數據集來測試它。 – semirturgay