Subsonic 3 Union Possible?

前端 未结 3 1778
甜味超标
甜味超标 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:52

    If the SQL queries generated to fill your anonymous types doesn't match, no way: you must do something like this:

    dd.ToList().AddRange(ss.ToList());
    

    And of course, this implies double request to your database.

    0 讨论(0)
  • 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<Menu>();
    

    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;
    
    0 讨论(0)
  • 2021-01-24 18:04

    Yeh, I'm the one that reports the LEFT OUTER JOIN problem. rob told me that the problem is by the Linq parser (Iqueryable provider impl). i think this is major issue because if u can't do more than just basic querys - you can't work with it at all...

    so push rob to fix it ASAP. :-).

    zahi.

    0 讨论(0)
提交回复
热议问题