1

How can i translate in linq lambda a query like this? I have two tables, i want to make a join with these conditions, is important for me having high performance, i need the linq query translate with join (not LEFT OUTER JOIN)

Select * from 
QRY
JOIN TABLE1  a1 ON qry.table1Id = a1.Id
join TABLE2 a2 ON

   (isnull(A1.FIELD1, '') != '' and isnull(a2.FIELD1, '') != '' and A1.FIELD1 = a2.FIELD1)
or (isnull(A1.FIELD2, '') != '' and isnull(a2.FIELD2, '') != '' and A1.FIELD2= a2.FIELD2)
or (isnull(A1.FIELD1, '') != '' and isnull(a2.FIELD2, '') != '' and A1.FIELD1= a2.FIELD2)
or (isnull(A1.FIELD2, '') != '' and isnull(a2.FIELD1, '') != '' and A1.FIELD2= a2.FIELD1)
where... some condition

is it possible in linq to do something like that or is necessary to make 2 queries?

stef
  • 45
  • 6
  • 1
    Possible duplicate of [Linq - left join on multiple (OR) conditions](https://stackoverflow.com/questions/1264993/linq-left-join-on-multiple-or-conditions) – SᴇM Jul 17 '19 at 13:25
  • See my [SQL to LINQ Recipe](https://stackoverflow.com/questions/49245160/sql-to-linq-with-multiple-join-count-and-left-join/49245786#49245786). – NetMage Jul 17 '19 at 18:46
  • This isn't really a question. What keeps you from doing it? Are struggling with the syntax, do you get errors, unexpected results? In other words, where in the SQL-to-LINQ translation process are you stuck? – Gert Arnold Jul 17 '19 at 18:57
  • @gert Arnold hi!... yes is am struggling with syntax... i would like to do the join that translated to sql would give me a similar query (i need high performances)... just wanted to know if it is possible or if i have to do something else (doing 2 queries), the question is just if i can do this in lambda... makethis crossed joins with or conditions in a join – stef Jul 19 '19 at 12:48

0 Answers0