LINQ To Entities doesn't recognize array index

后端 未结 2 1535
难免孤独
难免孤独 2021-01-25 00:02

I have following function in my code

  public List GetpathsById(List id)
        {

            List paths = new List<         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-25 01:05

    This question was asked by another user so it must be a school assignment.

    Basically I gave this same answer to the other user.

    It cannot be mapped to an SQL type or function.

    Everything you want doing in this code can be done simply using the list and iterating over it in a slightly different way.

    The following bit of code will do everything you need it to.

    public List GetpathsById(List id)  
    {
        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;  
    }  
    

提交回复
热议问题