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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:41:08+00:00 2026-05-23T15:41:08+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

I need query Entity Framework to retrive a list of Categories for a selected Content not associated in the Junction table.

At the moment I use this code (note the two FROM):

var categories = from category in context.CmsCategories
                 from content in category.CmsContents
                 select category;

That Returns a list of all category not associated in the entire database and not to a specific Content.

I need show the list of Categories not associates with a SPECIFIC Content

  • Any idea how to do it?
  • May I do it with JOIN? (EF does not map directly he Pure Junction Table)

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

  • 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-23T15:41:09+00:00Added an answer on May 23, 2026 at 3:41 pm

    You could try:

    CmsCategories.Except(myContent.CmsCategories)
    

    myContent is an instance of CmsContent, assuming you retrieved it before and you have lazy loading enabled.

    Edit: a possible sample of code:

    var myContent = context.CmsContents.FirstOrDefault(c => c.Id == 1);
    var contentCategories = myContent.CmsCategories;
    var otherCategories = context.CmsCategories.Except(contentCategories);
    foreach (var item in otherCategories)
    {
    //whatever you need to do
    }
    
    • 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.