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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:49:40+00:00 2026-05-24T13:49:40+00:00

I am using CodeFirst EntityFramework. I have a IQueryable<User> Entities that are returned using

  • 0

I am using CodeFirst EntityFramework. I have a IQueryable<User> Entities that are returned using context.Users; where context is DbContext of EntityFramework. From this list I have to choose those whose Id is contained in an array of Ids (long). Id is primary key of User entity. I have tried the following but getting compiler error.

IQueryable<User> users = GetQueryableUsers(); 
long [] ids = GetSelectedIds(); //array of long representing Ids key of User entities
users.Intersect(ids); // compilation error
users.Where(user => ids.Contains(user.Id)); //compilation error

Compilation error is (no definition found for Intersect/Contains)
Note: System.Linq is already imported.

  • 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-24T13:49:41+00:00Added an answer on May 24, 2026 at 1:49 pm

    Make sure you are referencing System.Linq

    e.g. using System.Linq

    Then user.Id must be of type long. You’ve stated in comments that it is long? because you believed that is how you needed to use the primary key. The solution is to use long and make use of the autogenerate id options of the entity framework.

    Alternatively a more general case for non primary keys that could be null would be to use the contains option with the value or default operator.

    users.Where(user=>ids.Contains(user.id??0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
I have been using Entity Framework CTP with Code-First as in this tutorial by
I have an ASP.NET MVC 3 app that is using SQL Server CE 4.0
I have looked around but cannot find anything that answered this particular question related
I'm using ASP.NET MVC 3 with Entity Framework CodeFirst I have two classes as
I have a pre-defined database that I want to map using Entity Framework 4
Say I have a database that stores table data by year using an identical
I have a product admin web site that has been generated using ASP.NET Dynamic
I'm trying to update an object that I have previously saved with EntityFramework 4.1

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.