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

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


        
6条回答
  •  渐次进展
    2020-11-30 08:51

    To fix this use a temporary variable:

    var tmp = aa[i];
    ...
    m => m.PresId == tmp
    

    In your where clause you have

    m => m.PresId == aa[i]
    

    which is a way of expressing a lambda expression. When that is converted to an expression, then converted into a query on your database it finds the aa[i], which is an index into an array. i.e. it doesn't treat it as a constant. Since a translation of an indexer to your database language is impossible it gives the error.

提交回复
热议问题