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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:51:44+00:00 2026-06-16T17:51:44+00:00

Given the schema below, I’m trying to build an EF query that returns Contacts

  • 0

Given the schema below, I’m trying to build an EF query that returns Contacts that are missing required Forms. Each Contact has a ContactType that is related to a collection of FormTypes. Every Contact is required to have at lease one Form (in ContactForm) of the FormTypes related to its ContactType.

The query that EF generates from the linq query below works against Sql Server, but not against Oracle.

var query = ctx.Contacts.Where (c => c.ContactType.FormTypes.Select (ft => ft.FormTypeID)
                            .Except(c => c.Forms.Select(f => f.FormTypeID)).Any());

I’m in the process of refactoring a data layer so that all of the EF queries that work against Sql Server will also work against Oracle using Devart’s dotConnect data provider.

The error that Oracle is throwing is ORA-00904: “Extent1″.”ContactID”: invalid identifier.

The problem is that Oracle apparently doesn’t support referencing a table column from a query in a nested subquery of level 2 and deeper. The line that Oracle throws on is in the Except (or minus) sub query that is referencing “Extent1″.”ContactID”. “Extent1” is the alias for Contact that is defined at the top level of the query. Here is Devart’s explanation of the Oracle limitation.

The way that I’ve resolved this issue for many queries is by re-writing them to move relationships between tables out of the Where() predicate into the main body of the query using SelectMany() and in some cases Join(). This tends to flatten the query being sent to the database server and minimizes or eliminates the sub queries produced by EF. Here is a similar issue solved using a left outer join.

The column “Extent1″.”ContactID” exists and the naming syntax of the query that EF and Devart produce is not the issue.

Any ideas on how to re-write this query will be much appreciated. The objective is a query that returns Contacts missing Forms of a FormType required by the Contact’s ContactType that works against Oracle and Sql Server.

enter image description here

  • 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-06-16T17:51:46+00:00Added an answer on June 16, 2026 at 5:51 pm

    The following entity framework query returns all the ContactIDs for Contacts missing FormTypes required by their ContactType when querying against both Sql Server and Oracle.

    var contactNeedsFormTypes = 
           from c in Contacts 
           from ft in c.ContactType.FormTypes
           select new { ft.FormTypeID, c.ContactID};
    
    var contactHasFormTypes = 
           from c in Contacts
           from f in c.Forms
           select new { c.ContactID, f.FormTypeID};
    
    var contactsMissingFormTypes = 
           from n in contactNeedsFormTypes
           join h in contactHasFormTypes
              on new {n.ContactID, n.FormTypeID} equals new {h.ContactID, h.FormTypeID}
                  into jointable
                  where jointable.Count()==0
    select n.ContactID;
    
    contactsMissingFormTypes.Distinct();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the schema below - with a query node as the context, is it
Below is schema description. I would like to construct a query that for a
I'm retrieving the files that match a given query in my drive account using
Table Schema For the two tables, the CREATE queries are given below: Table1: (file_path_key,
Given the Schema Displayed Below & MongoDB shell version: 2.0.4: How would I go
Table has schema of TIMESTAMP, PATIENTID, ECGVALUE and sample table is given below: 01.34
Given the contrived XML schema, sample XML input, and sample XSLT below used to
I have a student marks table with schema as given below: Student -------- SNO
my camel route is given below <camelContext id=camel xmlns=http://camel.apache.org/schema/spring > <route> <from uri=bean:SendClass?method=send />
Below is the XML schema I am trying to conform to: <?xml version=1.0 encoding=UTF-8?>

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.