The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities

后端 未结 6 1642
离开以前
离开以前 2020-11-30 08:16
public List GetpathsById(List id)
{
    long[] aa = id.ToArray();
        long x;
    List paths = new List();
         


        
6条回答
  •  天涯浪人
    2020-11-30 09:01

    public List GetpathsById(List id) 
    { 
            long x; 
        List paths = new List(); 
        foreach(long aa in id) 
        { 
            Presentation press = context.Presentations.Where(m => m.PresId == aa).FirstOrDefault(); 
            paths.Add(press.FilePath); 
        } 
        return paths; 
    } 
    

    to

    public IEnumerable GetpathsById(List id) 
    { 
        foreach(long item in id) 
            yield return = (context.Presentations.Where(m => m.PresId == item).FirstOrDefault()).FilePath
    } 
    

    "Short style", but not recomended if you write a lot of other function.

提交回复
热议问题