I am trying to use values in a related table.
I have 2 tables, menus and menus are related to one from the menu. MenuID == MenuID == MenuID
Currently, I am pulling this information using the following information
var menus = m to _context.Menus;
This is fed into a page and works fine.
I want to be able to sort the column menu section. Order
I have tried to do this:
var menus = m to _context.Menus include in MS at _context.MenuSections m.MenuId ms.MenuId's Equals ms.Order ascending selection meter;
But it is returning a set of data that is incorrect, it displays information about the menu repeatedly.
EDIT: To clarify what data I'm hoping for:
The menu has an X menu.
Each menu has several menu expressions
I want to list each menu and their respective menu searches. MenuSections should be in order based on MenuSection.Order. Order
Menu 1 - Menu 1, Order = 1 - Menu Section 3, Order = 2 Menu 2 - Menu address 4, Order = 1 - Menu address 2, Final = 2
round 3: This makes it very clear for the question Looks like you really need a group-by It's hard to get them right without IntelliSense, but I will try my best:
var groupings = m to _context. Menu order m.foo ms in m.MenuSections by order ms.Order M by Group MS; Foreign (group group) {menu menu = group. Of; Use the // menu foreach (group in menuSection ms) {// menuSection}}
Now I have an extra orderby m.Foo
where < Code> Foo is something I think you might want to do on menu
otherwise you are not guaranteed to know the command of top level menu.
Also note that what I was saying earlier was that m.MenuSections
is really helpful in MS by _context.MenuSections where ms.MenuId == m.MenuId
.
No comments:
Post a Comment