1
JOIN我有一個SQL查詢:顯示空結果使用LINQ
SELECT A.Codplano, A.Secao, A.Setor,A.Subsetor,A.Contato, ISNULL(B.Subord,'NÃO
LANÇADA')AS Situacao
FROM vwPLANODIN A LEFT JOIN LANCADA B
ON A.Codplano = B.Subord
and B.Data = '2014-06-10'
WHERE B.ID IS NULL and A.Sitio = 7341
寫在LINQ的:
var cob = from A in dataClass.vwPLANODINs
join B in dataClass.LANCADAs on new { A.Codplano, Data = data }
equals new { Codplano = B.Subord, Data = Convert.ToString(B.Data) } into B_join
from B in B_join.DefaultIfEmpty()
where
B.Data == null &&
A.Sitio == local
select new
{
A.Codplano,
A.Secao,
A.Setor,
A.Subsetor,
A.Contato,
Situacao = (B.Subord ?? "N/A")
};
我有沒有記錄一個GridView數據顯示,SQL查詢返回我需要的內容,但Linq查詢返回完全相反。