Есть ли способ сделать это менее многословным?
var model =
(
from MvrTable in
LinqEntitiesCtx.Mvrs
join MvrMedsTable in LinqEntitiesCtx.MvrMeds
.Where(Id => Id.FKMvrId == 1)//inner join will be fast with this!
on MvrTable.PKMvrId equals MvrMedsTable.FKMvrId
join MvrLocationTable in LinqEntitiesCtx.MvrLocations
on MvrTable.PKMvrId equals MvrLocationTable.FKMvrId
join MvrEmployeeTable in LinqEntitiesCtx.MvrEmployees
on MvrTable.PKMvrId equals MvrEmployeeTable.FKMvrId
//notice i am using a different primary key that previouslly
join MvrMedsAdminRouteTable in LinqEntitiesCtx.MvrMedsAdminRoutes
on MvrMedsTable.PKMvrMedsId equals MvrMedsAdminRouteTable.FKMvrMedsId
select new
{ //here I choose the columns I want to display
MvrTable.PKMvrId,
MvrTable.VarianceDescription,
MvrTable.CaseNumber,
MvrTable.DateOfReport,
MvrTable.DateOfVariance
}
);
Эквивалентный код SQL выше:
SELECT [t0].[PKMvrId], [t0].[VarianceDescription], [t0].[CaseNumber], [t0].[DateOfReport], [t0].[DateOfVariance], [t1].[PKMvrMedsId]
FROM [Mvrs] AS [t0]
INNER JOIN [MvrMeds] AS [t1] ON ([t0].[PKMvrId]) = [t1].[FKMvrId]
INNER JOIN [MvrLocations] AS [t2] ON ([t0].[PKMvrId]) = [t2].[FKMvrId]
INNER JOIN [MvrEmployees] AS [t3] ON [t0].[PKMvrId] = [t3].[FKMvrId]
INNER JOIN [MvrMedsAdminRoutes] AS [t4] ON ([t1].[PKMvrMedsId]) = [t4].[FKMvrMedsId]
WHERE [t1].[FKMvrId] =ParamMvrId