Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:01:34+00:00 2026-06-11T11:01:34+00:00

I have Window Application in VB.Net. I have following Classes & Enum. Public Class

  • 0

I have Window Application in VB.Net. I have following Classes & Enum.

Public Class Page
    Public Property Name As String
    Public Property PageItems As List(Of PageItem)
End Class


Public Class PageItem
    Public Property ItemName As String
    Public Property mode As Mode
End Class

Public Enum Mode
    Mode1
    Mode2
End Enum

In my application I have a List(Of Page) property. One Page may have multiple PageItemand also PageItem.ItemName can be duplicated with different modes. e.g. Application can have a PageItem with Mode1 and Mode2 (Here it’s possible that Mode1 item may in Page(0) and Mode2 item may in Page(1))

My Question is How to find a PageItems List (Same ItemName) which have both Mode1 and Mode2 from a List(Of Page) property using LINQ ?

Example:

Page 1 has 3 Items {Item1, Mode1}, {Item2,Mode1}, {Item3,Mode2}

Page 2 has 2 Items {Item1, Mode2}, {Item4, Mode1}

Here I want a PageItems list which have both mode Mode1 & Mode2. In the above case the result should be {Item1, Mode1}, {Item1, Mode2} (Item1 have both Modes)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:01:36+00:00Added an answer on June 11, 2026 at 11:01 am

    As you need “groups of PageItems”, I went for that approach:

    From p In pages From pi In p.PageItems _
     Group By pi.ItemName Into Group _
     Where (New Mode(){Mode.Mode1, Mode.Mode2}).All(Function(m) _
                   (From pig In Group Where pig.pi.Mode = m).Any) _
     Select ItemName, PageItems=(From pig In Group Select pig.pi)
    

    Note the final Select is reducing the available information. If you remove it you get the pages of each group too.

    To test this I used your data set except that I had Item3 with Mode2 (instead of adding a new Mode3 to the enumeration) and now to test the answer to your question in the comments I changed the Item4 to Item3, so that there are two groups returned for my above answer.

    The answer to “only get a List(Of PageItems)” is just a change to the last Select line:

    From p In pages From pi In p.PageItems _
     Group By pi.ItemName Into Group _
     Where (New Mode(){Mode.Mode1, Mode.Mode2}).All(Function(m) _
                   (From pig In Group Where pig.pi.Mode = m).Any) _
     From pig In Group Select pig.pi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario: - 64bit Windows Server 2008. - 32bit .NET application
I have a WPF application (.NET Framework 4) with a custom window-border. I've disabled
I have the following console application written in VB.NET: Sub Main() Dim ie As
I have developed a web application in asp.net, there is a page in this
I have a vb.net application that, when a short cut is pressed, a window
In an ASP.NET MVC3 project, I have 2 controllers: one is HomeController.cs public class
I have a windows forms application in .NET 3.5. There's one form with 20
Windows form application(.Net 3.5) I have a textbox and a button on the form.
I have one .net windows application I'm trying to read .xml file from c#
I have a windows application written in VB.net. After finishing it I'll setup the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.