当前位置: 代码迷 >> SQL >> linq 多个left join 跟 sql union all -> linq union 方法
  详细解决方案

linq 多个left join 跟 sql union all -> linq union 方法

热度:125   发布时间:2016-05-05 09:55:32.0
linq 多个left join 和 sql union all -> linq union 方法
 (
  from s in Base_SysMenus
  join r in Base_RoleRights on s.Menu_Id equals r.Menu_Id into temp
  from s_r in temp.DefaultIfEmpty()
 
  join u in Base_UserRoles on s_r.Roles_ID equals u.Roles_ID into temp2
  from t in temp2.DefaultIfEmpty()
  where s.Target=="Iframe" && t.User_ID=="48f3889c-af8d-401f-ada2-c383031af92d" && s.DeleteMark==1
  select new{Menu_Id= s.Menu_Id}
 ).Union(
  from s in Base_SysMenus
  join r in Base_UserGroupRights on s.Menu_Id equals r.Menu_Id into temp
  from s_r in temp.DefaultIfEmpty()
 
  join u in Base_UserInfoUserGroups on s_r.UserGroup_ID equals u.UserGroup_ID into temp2
  from t in temp2.DefaultIfEmpty()
  where s.Target=="Iframe" && t.User_ID=="48f3889c-af8d-401f-ada2-c383031af92d" && s.DeleteMark==1
  select new{Menu_Id= s.Menu_Id}
 ).Union(
  from s in Base_SysMenus
  join r in Base_UserRights on s.Menu_Id equals r.Menu_Id into temp
  from s_r in temp
  where s.Target=="Iframe" && s_r.User_ID=="48f3889c-af8d-401f-ada2-c383031af92d" && s.DeleteMark==1
  select new{Menu_Id= s.Menu_Id}
 )
 
  相关解决方案