Entity Framework学习 - 3.关联查询

1.Inner Join(默认)

var Goods = from goods in db.T_Goods
                    join types in db.T_GoodsType on goods.GoodsType equals types.GoodsTypeID
                    join priceinfo in db.T_PriceInfo on goods.PriceType equals priceinfo.PriceID

      select new XX{};

return Goods.ToList();

 

2.Left Join

var Goods = from goods in db.T_Goods
                    join types in db.T_GoodsType on goods.GoodsType equals types.GoodsTypeID into tempa
                    from a in tempa.DefaultIfEmpty()
                    join priceinfo in db.T_PriceInfo on goods.PriceType equals priceinfo.PriceID into tempb

      select new XX{};

return Goods.ToList();

posted @ 2015-08-09 01:49  朋克  阅读(199)  评论(0编辑  收藏  举报