Linq EF 内连怎么实现左/右连 急!!!!!!!!!谢谢~~~~~
var list = from c in list1
join m in SList
on c.ProId equals m.ProId
select new
{
m,
c.worktimesum ,
};
这样是内联(翻译成sql):
SELECT
1 AS [C1],
[Extent2].[ProId] AS [ProId],
[Extent2].[MaintenanceId] AS [MaintenanceId],
[Extent2].[ProName] AS [ProName],
[Extent2].[Tcontract] AS [Tcontract],
[Extent2].[TMonContract] AS [TMonContract],
[Extent2].[MaintenanceStart] AS [MaintenanceStart],
[Extent2].[MaintenanceEnd] AS [MaintenanceEnd],
[Extent2].[CreatedTime] AS [CreatedTime],
[Extent2].[CreatedBy] AS [CreatedBy],
[Extent2].[UpdatedTime] AS [UpdatedTime],
[Extent2].[UpdatedBy] AS [UpdatedBy],
[Extent2].[DeleteFlag] AS [DeleteFlag],
[GroupBy1].[A1] AS [C2]
FROM (SELECT
[Extent1].[ProId] AS [K1],
SUM([Extent1].[WorkTime]) AS [A1]
FROM [dbo].[M03_ProMaintenanceInfo] AS [Extent1]
GROUP BY [Extent1].[ProId] ) AS [GroupBy1]
INNER JOIN [dbo].[M02_ProInfo] AS [Extent2] ON [GroupBy1].[K1] = [Extent2].[ProId]
WHERE 0 = [Extent2].[DeleteFlag]
我想问的就是这个怎么写成左联,右连~~~~谢谢~~各位大神~~~~
------解决方案--------------------var list = from c in list1
join m in SList
on c.ProId equals m.ProId into left
from m in left.DefalutIfEmpty()
select new
{
c,
ProId=m==null?0:m.ProId
};