How to fix the error: LINQ to Entities does not recognize the method get_Item(Int32) method, and this method cannot be translated into a store expression.

Jump to: navigation, search

In my class, I am declaring ID as int. So I am not sure where Int(32) is coming from or why changing my code as shown below fixes the problem: Original version: var userInfoQuery = from item in dbContext.Users where item.ID == _userList[0].ID select item; userInfoQueryResult = userInfoQuery.FirstOrDefault(); //dies here Working version: int x = _userList[0].ID; //introducing this dummy int fixes the problem var userInfoQuery = from item in dbContext.Users where item.ID == x select item; userInfoQueryResult = userInfoQuery.FirstOrDefault(); //no errors

See also

Use your Android as a remote for garage door

Personal tools
Namespaces
Variants
Views
Actions
Navigation