I'm using Entity Framework 4.1 on a SQLCE 4 database and my context is a DbContext.
The purpose of the following code is to search for a list of entries where the "ProtocolName" property is contained within a given list.
This version of the code that supplies the list of permitted values as a List works fine:
List<string> lstPossibles = new List<string>("Name1", "Name2");
query = from le in context.DaLogEvents where lstPossibles.Contains(le.ProtocolName) select le;
However, this version of the code that supplies the permitted values as an array throws an exception when the query.ToList() is invoked:
string[] aryPossibles = new string[] { "Name1", "Name2" };
query = from le in context.DaLogEvents where aryPossibles.Contains(le.ProtocolName) select le;
The reported exception is:
"LINQ to Entities does not recognize the method 'Boolean Contains[String](System.String[], System.String)' method, and this method cannot be translated into a store expression."
It took me a while to figure out to use List rather than string[] because I've seen a fair number of references on this site to the use of the array method.
Is this an issue with just EF 4.1?