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 6023583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:01:37+00:00 2026-05-23T04:01:37+00:00

I have 3 classes (simplified for this question): public class Page { public Guid

  • 0

I have 3 classes (simplified for this question):

public class Page
{
    public Guid PageUid;
    public string PageTitle;
    public IQueryable<Keyword> Keywords;
}

public class News
    public Guid NewsUid;
    public string NewsTitle;
    public IQueryable<Keyword> Keywords;
}

public class Keyword
    public Guid KeywordUid;
    public string KeywordTitle;
}

I want to list all news-entries on a page where all (not any) keywords of this page matches with some or all of the keywords of the news. The page should display only news, where all the keywords of the page are present in the news. If one of the keywords of the page is not present in a news, this entry should not be displayed. But if the news-entry has more keywords than the page, the news should be displayed – if the keywords of the page are also present in the list of keywords of this news-item. If not, than the news should of course not be listed.

Quite complicated to explain, i try to sketch a real-life-example for better understanding:

Example:

The definitions are:

- PageA has 1 keyword:  Kw1
- PageB has 2 keywords: Kw1, Kw2
- PageC has 2 keywords: Kw1,      Kw3
- PageD has 3 keywords: Kw1, Kw2, Kw3

- NewsW has 1 keyword:  Kw1
- NewsX has 2 keywords: Kw1, Kw2
- NewsY has 2 keywords: Kw1,      Kw3
- NewsZ has 3 keywords: Kw1, Kw2,      Kw4

The results should be:

- PageA displays 4 items:       NewsW, NewsX, NewsY, NewsZ
- PageB lists 2 news:                  NewsX,        NewsZ
- PageC shows only 1 entry:                   NewsY
- PageD has not even one match.

The ‘linking’ element is the string ‘KeywordTitle’ and not the Guid ‘KeywordGuid’ or just the ‘Keyword’-object, because keywords should match if just the title (string) is identical.

In reality the 3 classes are tables in a database. I connect to the database with EntityFramework. The language is C#. The project is a ASP.NET MVC 3 Website.

The solution for my problem should be a LINQ-query if possible.

I hope someone has a solution for this – i tried so many different things, but had no success.

Thanks in advance for your help.

DanielD

  • 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-05-23T04:01:37+00:00Added an answer on May 23, 2026 at 4:01 am
    IEnumerable<News> news = …;
    Page page = …;
    var newsOnPage = news.Where(n => page.Keywords.All(pk => n.Keywords.Contains(pk)));
    

    This assumes comparing keywords by the default comparer works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As a simplified example, I have the following data classes: public class Employee {
I have some classes layed out like this class A { public virtual void
If I have classes of Type A and B: public class A { public
I have a simplified test scenario useful for asking this question: A Product can
I have next code that represents graph edges and nodes (simplified for question): public
I have models that look like this (simplified of course): class Product(models.Model): product_code =
As a simplified example, if I have the classes template <class T, class U>
I have classes which have automatic properties only like public customerName {get; set;}. They
I have an abstract class and subclasses of this, and I want to map
IT'S SIMPLIFIED CODE! I HAVE C++ FILES(WHERE IS IMPLEMENTATION) AND HEADERS FILES(WHERE IS CLASS

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.