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)

};

 
posted @ 2012-12-13 16:40  yellowshorts  阅读(2715)  评论(0编辑  收藏  举报