Je fonction suivante dans mon codeLINQ to Entities ne reconnaît pas l'index de tableau
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;
}
Mais quand j'essaie cela, compiller obtenir erreur comme ça. Ensuite, j'essaie de faire quelque chose comme ça et tout fonctionne bien.
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;
}
Alors je me demande pourquoi? Je ne peux obtenir aucune réponse pour ce comportement dans mon esprit. Quelqu'un peut-il expliquer ce paradoxe?
Je le pense aussi ... –
Merci ... Mais ne peut-il traduire simplement la valeur de cet index en SQL? –
Incroyable ... Et pourquoi 'Contient' fonctionne? –