LINQ with multiple ON in OR condition?

Asked

Viewed 32 times

0

I’m encountering a problem in the use of LINQ, I don’t have much knowledge of how it does. I have the following code:

(from BEN in repositorioBEN.RetornaTodos()
    join CON in repositorioCON.RetornaTodos() on BEN.Handle equals CON.Handle
    join APO in repositorioAPO.RetornaTodos() on CON.Apolice.Handle equals APO.Handle
    join PGD in repositorioPGD.RetornaTodos() on new
    {
        ben = BEN.Handle,
        con = CON.Handle,
        fam = BEN.Familia,
        est = APO.NroDoEstipulante,
        cor = APO.Corretor
    }
    equals new
    {
        ben = PGD.Beneficiario.Handle,
        con = PGD.Contrato.Handle,
        fam = PGD.Familia,
        est = PGD.HandleApolice,
        cor = PGD.Corretor
    }
    join TGE in repositorioTGE.RetornaTodos() on PGD.RegimeAtendimento.Handle.ToString() equals TGE.RegimeAtendimento
    where (PGD.DataFinal >= DateTime.Now && PGD.DataInicial <= DateTime.Now && BEN.Handle == idBeneficiario && TGE.Handle == idEvento)
    select new
    {
         QtdeDiasPagtoDiferenciado = PGD.QtdeDiasPagtoDiferenciado
    })
    .SingleOrDefault();

At the bottom, I need this condition to be OR and not AND.

How should I do?

join PGD in repositorioPGD.RetornaTodos() on new
    {
        ben = BEN.Handle,
        con = CON.Handle,
        fam = BEN.Familia,
        est = APO.NroDoEstipulante,
        cor = APO.Corretor
    }
    equals new
    {
        ben = PGD.Beneficiario.Handle,
        con = PGD.Contrato.Handle,
        fam = PGD.Familia,
        est = PGD.HandleApolice,
        cor = PGD.Corretor
    }

1 answer

0

there is no "OR" in the Line Join, only the Equals, in which case you will have to subquery the filter to return the data you need.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.