首页 新闻 搜索 专区 学院

sql转linq

0
悬赏园豆:15 [已解决问题] 解决于 2011-12-24 10:07

select * from RoleInfo
left join Role_menuInfo on Role_menuInfo.RoleId=RoleInfo.RoleId
left join MenuInfo on MenuInfo.MenuId=Role_menuInfo.MenuId
left join Role_GongorismpurviewInfo on RoleInfo.RoleId=Role_GongorismpurviewInfo.RoleId
left join GongorismpurviewInfo on GongorismpurviewInfo.GongorismId=Role_GongorismpurviewInfo.GongorismId

 

如何将这串sql语句转成linq语句???

急!!!!!

戴眼镜的男人的主页 戴眼镜的男人 | 初学一级 | 园豆:197
提问于:2011-12-23 10:56
< >
分享
最佳答案
0

from roleI in db.RoleInfo

                            join role_menu in db.Role_menuInfo on roleI.RoleId equals role_menu.RoleId
                            into role_menuEmpy

                            from role_em in role_menuEmpy.DefaultIfEmpty()

                            join menu in db.MenuInfo on role_em.MenuId equals menu.MenuId
                            into roleEmpty
                            from rEmpty in roleEmpty.DefaultIfEmpty()

                            join role_gong in db.GongorismpurviewInfo on rEmpty.MenuId equals role_gong.MenuId
                            into roleGong
                            from rolegong in roleGong.DefaultIfEmpty()

 

试试看这个

收获园豆:15
Mr、李 | 菜鸟二级 |园豆:206 | 2011-12-24 10:06
其他回答(1)
0

linq中也有left join 但是一般提倡用主表和子表的关系查询。select * from RoleInfo.Role_menuInfo中的RoleInfo.Role_menuInfo关系。

悟行 | 园豆:12371 (专家六级) | 2011-12-23 12:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册