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();

上一篇:Pots(bfs)


下一篇:js 动态声明变量