Reputation: 1863
for (int i = 0; i < list.Count; i++)
{
var doesrequestExist = cxt.Friends.FirstOrDefault(u => (u.User_Id == incID) &&
(u.Friend_UserId == (list.ElementAt(i).userid)) &&
(u.Request_Status == 0 || u.Request_Status == 1));
if (doesrequestExist != null)
{
}
i am getting error at "list.ElementAt(i).userid" error: LINQ to Entities does not recognize the method 'Int32 ToInt32(Int32)' method, and this method cannot be translated into a store expression.
Edit:
By removing the convert.toint32 in above query getting: LINQ to Entities does not recognize the method 'FriendsList ElementAt[FriendsList](System.Collections.Generic.IEnumerable`1[FR_Network.FR_Network+FriendsList], Int32)' method, and this method cannot be translated into a store expression.
Upvotes: 0
Views: 2706
Reputation: 2428
exclude Convert.ToInt32(list.ElementAt(i).userid)) from your linq.
for (int i = 0; i < list.Count; i++)
{
int friendId = Convert.ToInt32(list.ElementAt(i).userid);
var doesrequestExist = cxt.Friends.FirstOrDefault(u => (u.User_Id == incID) &&
(u.Friend_UserId == friendId &&
(u.Request_Status == 0 || u.Request_Status == 1));
if (doesrequestExist != null)
{
}
}
Upvotes: 1