How can I add one more condition in a join?
I have the query below;
var consultaVeiculo = (from e in dm.Tabela_SegVeiculos
join r in dm.Tabela_VeiculoRefers
on e.Modelo equals r.Cod_referencia
into veicRef
from Referencia in veicRef.DefaultIfEmpty()
where e.Seguradora == idSeguradora
orderby e.Modelo_cia
select new { Descricao = Referencia == null ? "" : Referencia.Descricao, e });
It generates the following query in the sql server:
SELECT
(CASE
WHEN [t2].[test] IS NULL THEN CONVERT(NVarChar(50),'')
ELSE CONVERT(NVarChar(50),[t2].[Descricao])
END) AS [Descricao], [t0].[Seguradora], [t0].[Veic_cia], [t0].[Fabricante], [t0].[Modelo_cia], [t0].[Modelo], [t0].[Categ_AT], [t0].[Situacao], [t0].[Data_inclusao], [t0].[Data_alteracao], [t0].[COD_FIPE]
FROM [dbo].[Tabela_SegVeiculos] AS [t0]
LEFT OUTER JOIN (
SELECT 1 AS [test], [t1].[Descricao], [t1].[Cod_referencia]
FROM [dbo].[Tabela_VeiculoRefer] AS [t1]
) AS [t2] ON [t0].[Modelo] = ([t2].[Cod_referencia])
WHERE ([t0].[Seguradora] = 83) AND ([t2].[Cod_referencia] > 0)
ORDER BY [t0].[Modelo_cia]
I need to add ON [t0].[Modelo] = ([t2].[Cod_referencia])
right after and [t2].[Cod_referencia] > 0
.
I have tried to do this in the form below, but as shown in the image it displays an error.