I want to compare a sting field with a string array using LINQ, I’ve written the below extension method for comparing but it doesn’t work correctly.
public static bool Contains(this string source, string[] keys)
{
foreach (var item in keys)
{
if (source.Contains(item))
return true;
}
return false;
}
And this is my query:
string[] keys = key.Split('+');
var pages = context.Pages.Where(x => x.Title.Contains(keys));
The error that I’ve got is:
LINQ to Entities does not recognize the method 'Boolean Contains(System.String, System.String[])' method, and this method cannot be translated into a store expression.