嘿伙计们,我在使用LINQ&创建以下sql语句时遇到问题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
我懂了
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); }
这不是正确的加入,所以任何想法?
解决方法
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 };