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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:14:24+00:00 2026-06-04T16:14:24+00:00

What would be an EF method syntax equivalent for the following TSQL query? select

  • 0

What would be an EF method syntax equivalent for the following TSQL query?

select istb.service_id, ss.service_desc, selected=1
from istb_services istb
inner join setup_services ss on istb.service_id=ss.service_id
where istb.istb_id=3
union
select ss.service_id, ss.service_desc, selected=0
from setup_services ss
where ss.service_id not in (select service_id from istb_services where istb_id=3)

I tried converting the not in part of the query like following:

var _existing = context.istb_services.Where(e => e.istb_id == IstbID);
var _others = context.setup_services.Except(_existing);

but it is generating compile-time error:

The best overloaded method match for ‘System.Data.Objects.ObjectQuery.Except(System.Data.Objects.ObjectQuery)’ has some invalid arguments

I understand I can’t pass different type of ObjectQuery to the .Except method but then what would be the alternative code?

Thanks,

  • 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-04T16:14:25+00:00Added an answer on June 4, 2026 at 4:14 pm

    Try the following:

    var resultA = 
        from istb in istb_services 
        join ss in setup_services on istb.service_id equals ss.service_id
        where istb.istb_id == 3
        select new { istb.service_id, ss.service_desc, selected = true };
    
    var resultB =            
        from ss in setup_services 
        where !istb_services.Any(istb => 
            istb.service_id == ss.service_id &&
            istb.istb_id == 3)
        select new { ss.service_id, ss.service_desc, selected = false };
    
    var result = resultA.Union(resultB);
    

    Anonymous type initializers having identical fields should be compiled to the same anonymous type, making the two sequences compatible for the Union operation.

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

Sidebar

Related Questions

How would the following query look if I was using the extension method syntax?
I need the equivalent of this SQL statement in Linq, using method/fluent syntax. SELECT
I was wondering what the parameters from this method would return. - (void) observeValueForKeyPath:(NSString
I tried to solve problems from Project Euler. I know my method would work
Recently I wrote this query with Linq (Method Syntax), notes: g.CmsContents is a Navigatiola
Using pubs If I want to join using query syntax I would do this.
[EDIT 1 - added third pointer syntax (Thanks Alex)] Which method would you prefer
Linq and EF4. I have this Linq query in query syntax I would like
What method would you use to determine if the the bit that represents 2^x
In Java, a 'static method' would look like this: class MyUtils { . .

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.