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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:14:26+00:00 2026-05-28T14:14:26+00:00

I’m by far not a LINQ master, but I’m getting into some complex queries

  • 0

I’m by far not a LINQ master, but I’m getting into some complex queries now that I’ve rolled my Data Access Layer into Entity Framework 4. The following is the SQL I have converted into LINQ

select DISTINCT DegreeCategories.CategoryTitle 
from DegreeCategories

inner join Degrees on DegreeCategories.DegreeCategoryID = Degrees.DegreeCategoryDegreeCategoryID
inner join Programs on Programs.DegreesDegreeID = Degrees.DegreeID
inner join ProgramCategories on Programs.ProgramCategoriesCategoryID = ProgramCategories.CategoryID
inner join OccuPathBridge on OccuPathBridge.ProgramCategoryID = ProgramCategories.CategoryID
inner join CareerMap on OccuPathBridge.OccupationID = CareerMap.OccupationID

where Programs.DegreesDegreeID in ( 
            select Degrees.DegreeID from Degrees where Programs.ProgramCategoriesCategoryID in
                ( select ProgramCategories.CategoryID from ProgramCategories where CategoryID in 
                    ( select OccuPathBridge.ProgramCategoryID from OccuPathBridge where OccuPathBridge.OccupationID in
                        (select OccupationID from CareerMap where CareerMap.OccupationTitle = 'Pharmacists')
                    )
                )
            )

The Linq as best I can tell is 1:1 – however the containing type does not contain a method for “Contains()” which is causing the expression to fail all together.

(from degreecategories in db.DegreeCategories
join degrees in db.Degrees on new { DegreeCategoryID = degreecategories.DegreeCategoryID } equals new { DegreeCategoryID = degrees.DegreeCategoryDegreeCategoryID }
join programs in db.Programs on new { DegreesDegreeID = degrees.DegreeID } equals new { DegreesDegreeID = programs.DegreesDegreeID }
join programcategories in db.ProgramCategories on new { ProgramCategoriesCategoryID = (Int32)programs.ProgramCategoriesCategoryID } equals new { ProgramCategoriesCategoryID = programcategories.CategoryID }
join occupathbridges in db.OccuPathBridges on new { ProgramCategoryID = programcategories.CategoryID } equals new { ProgramCategoryID = (Int32)occupathbridges.ProgramCategoryID }
join careermaps in db.CareerMaps on occupathbridges.OccupationID equals careermaps.OccupationID
where
    (from degrees0 in db.Degrees
    where

        (from programcategories0 in db.ProgramCategories
        where

            (from occupathbridges0 in db.OccuPathBridges
            where

                (from careermaps0 in db.CareerMaps
                where
                  careermaps0.OccupationTitle == "Pharmacists"
                select new {
                  careermaps0.OccupationID
                }).Contains(new { occupathbridges0.OccupationID })
            select new {
              occupathbridges0.ProgramCategoryID
            }).Contains(new { ProgramCategoryID = (Int32?)programcategories0.CategoryID })
        select new {
          programcategories0.CategoryID
        }).Contains(new { CategoryID = (Int32)programs.ProgramCategoriesCategoryID })
    select new {
      degrees0.DegreeID
    }).Contains(new { programs.DegreesDegreeID })
select new {
  degreecategories.CategoryTitle
}).Distinct()

Where do I begin to start translating this query into a Parallel Query?

I’ve included all the requisite includes

using System.Linq;
using System.Data.Entity;
using System.Data.Linq;
using MyProjects.DAL;

Is there something obvious I’m missing? I’ve used Linqer, Linqpad, and several tutorials out there on google to try and write sub-select based queries. none of which have yielded any results.

  • 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-28T14:14:27+00:00Added an answer on May 28, 2026 at 2:14 pm

    As just one example of what’s wrong with the SQL version, we have this:

     in ( 
            select Degrees.DegreeID from Degrees where Programs.ProgramCategoriesCategoryID in
    

    Since the WHERE clause here isn’t referencing the Degrees table at all, that’s effectively selecting all rows from that table. So, it seems to be a null operation.

    Can you confirm if the following query gives equivalent results:

    select DISTINCT DegreeCategories.CategoryTitle 
    from DegreeCategories
    
    inner join Degrees on DegreeCategories.DegreeCategoryID = Degrees.DegreeCategoryDegreeCategoryID
    inner join Programs on Programs.DegreesDegreeID = Degrees.DegreeID
    inner join ProgramCategories on Programs.ProgramCategoriesCategoryID = ProgramCategories.CategoryID
    inner join OccuPathBridge on OccuPathBridge.ProgramCategoryID = ProgramCategories.CategoryID
    inner join CareerMap on OccuPathBridge.OccupationID = CareerMap.OccupationID
    where CareerMap.OccupationTitle = 'Pharmacists'
    

    Then we can look at converting it to an EF/LINQ query.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.