score:0

Accepted answer

I figured it out. Since I can't use the Any keyword, I used this function:

    public static bool ContainsAny(this string databaseString, List<string> stringList)
    {
        if (databaseString == null)
        {
            return false;
        }
        foreach (string s in stringList)
        {
            if (databaseString.Contains(s))
            {
                return true;
            }
        }
        return false;
    }

So then I can use this expression in my Where clause:

expression = i => i.Domains.ContainsAny(_mainDomains);

Update: According to usr, the query would return all the values and execute the where clause server side. A better solution would be to use a different approach (and not use stuffed/comma-separated values)

score:3

You can use contains:

where i.Domains.Any(s => _mainDomains.Contains<string>(s.xxx))

Notice that the generic arguments are required (even if Resharper might tell you they are not). They are required to select Enumerable.Contains, not List.Contains. The latter one is not translatable (which I consider an error in the L2S product design).

(I might not have gotten the query exactly right for your data model. Please just adapt it to your needs).


Related Query

More Query from same tag