-1

I have this MySQL query which does what I want. But I don't know how to translate this query to linq, the part of the UNION is what confuses me.

The MYSQL query:

SELECT * FROM conta.subrecurso as a 
left join conta.recurso as b on a.idRecurso=b.idRecurso
left join conta.eventorecurso as c on b.idRecurso=c.idRecurso
left join conta.recursocliente as d on a.idSubrecurso=d.idSubrecurso
left join conta.eventocliente as e on d.idVenta=e.idVenta
where c.idEvento=47  And  e.idVenta =784
UNION 
SELECT * FROM conta.subrecurso as a 
left join conta.recurso as b on a.idRecurso=b.idRecurso
left join conta.eventorecurso as c on b.idRecurso=c.idRecurso
left join conta.recursocliente as d on a.idSubrecurso=d.idSubrecurso 
left join conta.eventocliente as e on d.idVenta=e.idVenta
WHERE c.idEvento=47 and e.idVenta is null ;
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • Possible duplicates: http://stackoverflow.com/questions/21884424/convert-sql-left-outer-join-to-linq and http://stackoverflow.com/questions/2744205/how-to-convert-sql-union-to-linq – vyrp Mar 26 '17 at 06:17
  • Also, can't you combine the two queries in one with an OR? `WHERE c.idEvento=47 and (e.idVenta=784 or e.idVenta is null);` – vyrp Mar 26 '17 at 06:18

1 Answers1

1

There's a similar question. In the answer the solved it in that way:

(sqlstatement1).Union(sqlstatement2);
Community
  • 1
  • 1
Archimedes
  • 231
  • 1
  • 2
  • 13