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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:50:06+00:00 2026-06-14T22:50:06+00:00

I have to select some items from a database. The IDs of the items

  • 0

I have to select some items from a database. The IDs of the items are in a List.

In an answer here, Jon Skeet states that we might use Contains()

var foo = channel.AsQueryable<CodeData>()
                 .Where(codeData => codeIDs.Contains(codeData.CodeId));

In a context where the database is huge and the IDs list is really small, how does it perform?

Is Linq smart enough to use the IN clause in SQL?

Edit: I am using DataContext and SQL Server 2008

  • 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-14T22:50:07+00:00Added an answer on June 14, 2026 at 10:50 pm

    Yes, LINQ 2 SQL would use the IN clause in this scenario.

    But not because it is “smart” and detects that you have a huge DB and a small id list.

    The IN clause is how LINQ 2 SQL “knows” to express the List.Contains in SQL.


    In fact, if you had a list of 1000 items you’ll see an IN clause with 1000 parameters.

    If you have a list of more than 2100 ids, you’ll hit a limitation in the SQL Client that does not allow more than 2100 parameters on a command. But LINQ 2 SQL would happily generate a command that has, for example, even 5000 parameters.

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

Sidebar

Related Questions

I have the problem, that MSSQL Server 2000 should select some distinct values from
I have a list of words that I want to exclude from some query
I have to list several elements that are coming from a database source A
I need some help please. I have this from my database: SELECT DISTINCT iwi.item
I have the query to select some columns from two tables, which must contain
Suppose i have 1kk records in my database. Now i need to select some
I have a function in my model for selecting items from a database and
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have some tables in a MySQL database to represent records from a sensor.
I have to pull a list of integer IDs from a table using only

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.