linq to Entity 实现 left join

from u in usergroups from p in u.UsergroupPrices
select new UsergroupPricesList
     {

     UsergroupID= u.UsergroupID,

     UsergroupName= u.UsergroupName,

     Price= p.Price

   }

Left Join

var query =from u in usergroups

join p inUsergroupPrices on u equals p.UsergroupIDinto gj

from x in gj.DefaultIfEmpty()

selectnew{

UsergroupID= u.UsergroupID,

UsergroupName= u.UsergroupName,

Price=(x ==null?String.Empty: x.Price)

};

 
乌龟才背着房子过一辈子
原文地址:https://www.cnblogs.com/Yellowshorts/p/2816615.html