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 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

I use c#, linq and EF4. I have two tables in my DataBase represented
I use c#, linq and EF4. I have two tables in my DataBase represented
I use LINQ, C#, EF4. I have this query expression in Linq. I need
I use C#, Linq and EF4. I have a front end for my website,
I use c# asp-net 4 and ef4. I have a LINQ query which create
I use Linq-to-SQL which will generate classes for database tables dragged to its designer.
I use LINQ-SQL as my DAL, I then have a project called DB which
While trying to use LINQ to SQL I encountered several problems. I have table
Is it possible to use precompiled linq queries with repositories. Current I have my
I use asp.net 4 c# and ef4. I have this code, it should compile

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.