I have following function in my code
public List<string> GetpathsById(List<long> id)
{
List<string> paths = new List<string>();
for (int i = 0; i < id.Count; i++)
{
Presentation press = context.Presentations.Where(m => m.PresId == id[i]).FirstOrDefault();
paths.Add(press.FilePath);
}
return paths;
}
But when I try this, compiller get error like this.
LINQ to Entities does not recognize the method 'Int64 get_Item(Int32)' method, and this method cannot be translated into a store expression.
Then I try to do something like this and all works fine.
public List<string> GetpathsById(List<long> id)
{
long x;
List<string> paths = new List<string>();
for (int i = 0; i < id.Count; i++)
{
x = id[i];
Presentation press = context.Presentations.Where(m => m.PresId == x).FirstOrDefault();
paths.Add(press.FilePath);
}
return paths;
}
So I wonder, why? I can't get any answer for that behaviour in my mind. Can anyone explain this paradox?