Subsonic 3 Union Possible?

前端 未结 3 1815
甜味超标
甜味超标 2021-01-24 16:58

I have a schema like so. Menu->Pages->PageRoles->ASPNetRoles

Menu has a CategoryID.

I want to return all Menu items with a CategoryID of 6.

Some Menu ite

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-24 17:59

    It looks like you're bumping into a bug in SubSonic's implementation of Union/Concat, you should report it to the google code site. You should just be able to do the following, which I'm pretty sure you'd already worked out:

    var unionList = dd.Concat(ss).ToList();
    

    In the meantime the following should be pretty close to the outer join you're after:

    var ss =  from menu in Menu.All()
        group join pages in WebPage.All() on menu2.PageID equals pages.ID
          into pagesMenu from pm in pagesMenu.DefaultIfEmpty()
        group join pagesRoles in PageRole.All() on pages.ID equals pagesRoles.PageID
          into pagesRolesPages from prp in pagesRolesPages.DefaultIfEmpty()
        group join roles in aspnet_Role.All() on pagesRoles.RoleId equals roles.RoleId
          into pagesRolesRoles from prr in pagesRolesRoles.DefaultIfEmpty()
      where menu.PageID == null || 
        (Roles.GetRolesForUser().Contains(roles.RoleName) && menu2.CategoryID == 6)
      select menu;
    

提交回复
热议问题