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

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.


Apparently, if you use an array index (aa[i]) inside an expression tree, it tries to convert that into an expression as well.

Just work around it by using a separate variable:

int presId = aa[i];
Presentation press = context.Presentations.Where(m => m.PresId == presId).FirstOrDefault();