小编Dav*_*son的帖子

LINQ to Entities不支持LINQ表达式节点类型'ArrayIndex'

public List<string> GetpathsById(List<long> id)
{
    long[] aa = id.ToArray();
        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 == aa[i]).FirstOrDefault();
        paths.Add(press.FilePath);
    }
    return paths;
}
Run Code Online (Sandbox Code Playgroud)

此代码抛出以下异常: The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities.

但是,如果我提供x而不是aa[i]它的工作.

为什么?

c# linq arrays linq-to-entities entity-framework

56
推荐指数
3
解决办法
3万
查看次数

标签 统计

arrays ×1

c# ×1

entity-framework ×1

linq ×1

linq-to-entities ×1