Possible Duplicate:
LINQ: Check whether an Array is a subset of another
I am trying to determine if there is a way to use LINQ to find if every element in a subset array is in a superset array. For example with this superset:
{'w','o','k','r','d','o'}
The following would be a valid Subset:
{'o','k','w','r'}
While these would not be valid:
{'o','k','w','r','s'}
{'w','o','k','r','d','o','s'}
The actual superset is a char array that I have in memory. The actual subset is a value in a database table. I am trying to use LINQ to EF to get all values out of the table that meet this condition. This is what I have tried so far:
char[] letterArray = letters.ToCharArray();
return we.Words.Where(t => letterArray.Join(t.Word.ToCharArray(),
f => f,
s => s, (f, s) => new { s }).Count() == t.Word.Length
).Select(t => t.Word).ToArray();
But when I run this I get the error:
'Unable to create a constant value of type 'System.Char'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.'
Is there a way around this error? Is there an easier way to do what I am trying here?