How to make a right join using LINQ to SQL & C#?

后端 未结 2 1115
野趣味
野趣味 2020-12-06 19:07

I have a problem creating the following SQL Statement using LINQ & C#

    select c.IDAddenda, c.Descripcion
      from CatAddendas c 
right join EmpresaAd         


        
相关标签:
2条回答
  • 2020-12-06 19:27
    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 apply where and order by on the results.

    0 讨论(0)
  • 2020-12-06 19:35
     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 
                     };
    
    0 讨论(0)
提交回复
热议问题