Hello, I wrote this LINQ code:
from workTask in VwWorkTask.Where(e => e.TaskStateStr != "A"
&& e.TaskStateStr != "B")
join workContext in TblWorkTOBProlongationWorkContexts
on workTask.WorkContextId equals workContext.Id
join client in VwClient
on workContext.Client equals client.ClientId into t1
from client in t1.DefaultIfEmpty()
....// other joins
select workTask
Which generates this T-SQL query:
SELECT [t0].*
FROM [vwWorkTask] AS [t0]
INNER JOIN [tblWorkTOBProlongationWorkContext] AS [t1]
ON [t0].[WorkContextId] = ([t1].[Id])
LEFT OUTER JOIN [vwClient] AS [t2] ON [t1].[Client] = [t2].[ClientId]
... -- other joins
WHERE ([t0].[TaskStateStr] <> @p0) AND ([t0].[TaskStateStr] <> @p1)
But I`m need something like that instead:
SELECT [t0].*
FROM [select * vwWorkTask WHERE ([t0].[TaskStateStr] <> @p0)
AND ([t0].[TaskStateStr] <> @p1)] AS [t0]
INNER JOIN [tblWorkTOBProlongationWorkContext] AS [t1]
ON [t0].[WorkContextId] = ([t1].[Id])
LEFT OUTER JOIN [vwClient] AS [t2] ON [t1].[Client] = [t2].[ClientId]
... -- other joins
In other words I need nested query with "where" check before all joins, not after. Any ideas how can I rewrite LINQ query to accomplish that?
Thanks.