I have a many to many relationship (Sites, Categories, CategoriesXSite), I need to get all categories filtering by certain site names so I did my homework and made this linq:
var filteredcategories = from c in context.Categories
from s in c.Sites
where s.Name.Contains(siteWord)
select c;
it works perfectly, the thing is I already have a method that filters sites and I want to reuse it like this:
var filteredcategories = from c in context.Categories
where c. Sites == FilterSites(siteWord)
select c;
this is my filter method:
public IQueryable<Site> FilterSites(string word)
{
return (from s in context.Sites
where s.Name.Contains(word)
select s);
}
Is this possible to accomplish?
Thanks in advance!