How to make the right join using LINQ to SQL & C #

Hi guys, I had a problem creating the following SQL statement using LINQ and C #

select c.IDAddenda, c.Descripcion from CatAddendas c right join EmpresaAddenda e on e.IDAddenda = c.IDAddenda where e.rfc = 'SUL010720JN8' order by c.IDAddenda asc 

I got it

 public IEnumerable<CatAddenda> TraeAddendas(string rfc) { DataClasses1DataContext dc = new DataClasses1DataContext(...); return (from adds in dc.EmpresaAddendas cats.IDAddenda into joined where adds.RFC == rfc select adds.CatAddenda); } 

This does not make the correct connection, so any ideas?

+4
source share
2 answers
  var RightJoin = from adds in dc.EmpresaAddendas join cats in CatAddendas on adds.IDAddenda equals cats.IDAddenda into joined from cats in joined.DefaultIfEmpty() select new { Id = cats.IDAddenda, Description = cats.Descripcion }; 
+9
source
 var results = from e in EmpresaAddenda join c in CatAddendas on e.IDAddenda equals c.IDAddenda into f from c in f.DefaultIfEmpty() select new { ID = c.IDAddenda, Description = c.Descripcion }; 

You can indicate where and in order, according to the results.

+4
source

Source: https://habr.com/ru/post/1403991/


All Articles