Linq中包含查询
//Linq代码:
T_WxMaterials.Where(n=>T_VideoMsgs.Select(m=>m.MediaID).Contains(n.MediaID))
//生成的sql语句:
SELECT [t0].[ID], [t0].[Type], [t0].[Title], [t0].[Cnt], [t0].[MediaID], [t0].[LocalPath], [t0].[WxPath]
FROM [T_WxMaterial] AS [t0]
WHERE EXISTS(
SELECT NULL AS [EMPTY]
FROM [T_VideoMsg] AS [t1]
WHERE [t1].[MediaID] = [t0].[MediaID]
)
Linq中不包含查询
//Linq代码:
T_WxMaterials.Where(n=>!T_VideoMsgs.Select(m=>m.MediaID).Contains(n.MediaID))
//生成的sql语句:
SELECT [t0].[ID], [t0].[Type], [t0].[Title], [t0].[Cnt], [t0].[MediaID], [t0].[LocalPath], [t0].[WxPath]
FROM [T_WxMaterial] AS [t0]
WHERE NOT (EXISTS(
SELECT NULL AS [EMPTY]
FROM [T_VideoMsg] AS [t1]
WHERE [t1].[MediaID] = [t0].[MediaID]
))