1

I'm trying to convert this SQL code to linq sql. But I don't understand even with the doc... someone can help me please ?

select prcleunique, LibelleProjet, from projet a
where eqcleunique in (select EqCleunique from Compo where uscleunique = '{0}') 
and (a.socleunique in (select socleunique from utilisat where uscleunique = '{0}') or a.socleunique is null) 
and a.archive = 2 order by LibelleProjet", idUtilisateur);
Phantom
  • 19
  • 2
  • Perhaps my [SQL to LINQ Recipe](https://stackoverflow.com/questions/49245160/sql-to-linq-with-multiple-join-count-and-left-join/49245786#49245786) could guide you. – NetMage May 15 '19 at 17:48

1 Answers1

0

Those nested sql queries can be broken down nicely in Linq. Every time you have a select have a seperate linq query:

var clause1 = from row in _db.Compo where uscleunique == '{0}' select EqCleunique;

Then use the clauses in the last query

var result = from row in _db.project where clause1.Contains(row.eqcleunique) select row.whatever;

I hope this example is enough to get you started.

Thomas Koelle
  • 3,416
  • 2
  • 23
  • 44