I am trying to write an extention method for a repository. The repository has a method IQueryable<parent>
GetAll(). I want to create an extention method FilterByChildId(int childId) so that I can write:
List<parent> data = from d in repository.getAll().FilterByChildId(33).ToList()
Not sure how to do the join on the parent and child inside the extension method. I thoudht it would be something like:
public static IQueryable<parent> FilterByChildId(
this IQueryable<parent> query,
int id)
{
return from data in query where data.child.id == id select data
}
but not a chance. I tried all sorts of variations using join, groupjoin but not clicking. Any help would be appreciated.