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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:41:44+00:00 2026-05-20T11:41:44+00:00

OK, this thing just puzzles me. I have a table, say Users, with columns

  • 0

OK, this thing just puzzles me.
I have a table, say Users, with columns UserID, Name, etc. Have an object mapped to it using CTP5. So now I want to test it, and do the following:

List<User> users = new List();
// Some init code here, making say 3 users.
using (UsersDbContext)
{
  // insert users
}

So far so good, works fine.
Now I want to see if the records match, so I select the users back using the following code.

using (UsersDbContext dbc = UsersDbContext.GetDbContext())
{
List<Users> usersRead = dbc.Users.Where(x => x.ID >= users[0].ID && x.ID <= users[users.Count - 1].ID).ToList();
}

This throws and exception:

System.NotSupportedException: LINQ to
Entities does not recognize the method
‘User get_Item(Int32)’ method, and
this method cannot be translated into
a store expression.

EF has difficulties seeing that I’m just asking to return an int in Users[0].ID ?
If I replace a call to users[0].ID with a straight int – works fine.

I get what it’s trying to do, but I thought it should be pretty easy to check if the method belongs to .NET or Sql Server ?

  • 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-20T11:41:45+00:00Added an answer on May 20, 2026 at 11:41 am

    You are trying to access an indexer in an EF expression, which doesn’t translate to an SQL query. You’ll have to move the parameters outside the query like this:

    int first = users[0].ID;
    int last = users[users.Count - 1].ID;
    List<Users> usersRead = dbc.Users.Where(x => x.ID >= first && x.ID <= last).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an odd thing I've just run into. I have a web application
This seemed like an easy thing to do. I just wanted to pop up
I just want to clarify one thing. This is not a question on which
I'm not sure if this is a bug or just some crazy new thing
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
this funny thing called FBML http://developers.facebook.com/docs/reference/fbml/ I'm just wondering is it true that any
This sounds dumb, but I can't get it to work. I think i just
I think I know how to handle this case, but I just want to
I'm just finishing up a computer architecture course this semester where, among other things,
This is a self-explanatory question: Why does this thing bubble into my try catch's

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.