string[] userIds = userList.Split(','); // is an array of integers
IList<User> users = (from user in this.repository.Users
where userIds.Contains(user.Id.ToString())
select user).ToList();
the above query gives
System.NotSupportedException: LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression
What can I do?
Avoid the call to
ToString. You want something like this:To make this work the list
userIdsmust be a collection of the type whichuser.Idhas. If you want integers then useint.Parseto convert the strings to integers: