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

  • Home
  • SEARCH
  • 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 4061994
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:32:33+00:00 2026-05-20T15:32:33+00:00

I use c#, linq and EF4. I have two tables in my DataBase represented

  • 0

I use c#, linq and EF4.

I have two tables in my DataBase represented in my Conceptual Model:

DataBase Tables:

CmsContents
CmsCategories
CmsRelatedCategories (Pure Juction Table)

Entity Type:

CmsContent
CmsCategory

Entyt Set:

CmsContents
CmsCategories

I have some Navigational Properties:

for CmsContents --> CmsCategories --> Return Collection of Cms CmsCategory
for CmsCategories --> CmsContents --> Return Collection of Cms CmsContents

Data in DataBase for the Junction Table is presented:

CategoryId     ContentId
7              1
7              2
9              2

I need query Entity Framwork to retrive all CmsContents which are included in the Junction Table.

At the moment I use this code:

var contents = from cnt in context.CmsContents
                               where cnt.CmsCategories.Any()
                               select cnt;

That Returns:

CmsContents
1
2

I need the result showing instead:

CmsContents
1
2
2

I suspect that Any() show me just DISTINCT values, but I need all values listed.

Any idea how to solve it?.

Could you please write me the LINQ query so I can have a clear picture.

  • 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-20T15:32:33+00:00Added an answer on May 20, 2026 at 3:32 pm

    Any() doesn’t return values at all – it returns a Boolean value as to whether there are any values in the collection or not. It’s just showing two values because you’re only querying CmsContents, which has two rows, and both rows have at least one category, so both rows are in the result.

    It looks like you’re really after something like:

    var contents = from cnt in context.CmsContents
                   from category in cnt.CmsCategories
                   select cnt;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While trying to use LINQ to SQL I encountered several problems. I have table
I've just started to use linq to sql and have run into a problem
I recently started to use LINQ to SQL and i have a minor complex
I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I
Assuming you can't use LINQ for whatever reason, is it a better practice to
I would like to use Linq to Xml to get a single XElement from
I would like to use Linq to query a bus schedule in my project,
How can I use Linq with Dataset.xsd files? I've looked at Linq-to-Datasets and Linq-to-XSD
Is it possible to use LINQ in win32 DELPHI applications
I decided to use LINQ to SQL in my personal project after hearing lots

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.