I have say three tables.
Projects
- Id
- Name
Categories
- Id
- Name
ProjectCategories
- Id
- ProjectId
- CategoryId
I now have an array of strings which represents categories the user has elected to search on. I now need to find all the projects that have those category attached to them.
I tried;
string[] searchTerms = new string[2];
searchTerms[0] = "paint";
searchTerms[1] = "painting";
IQueryable<Project> projects = (from category in dc.ProjectCategories
where searchTerms.Any(val => category.Category.Name.Contains(val))
select category.Project).Distinct();
But I get the error;
{"Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator."}