I think this is your answer :
http://stackoverflow.com/questions/534690/linq-to-sql-return-anonymous-type[
^]
So you need to define a class like this :
public class PersonPet
{
public string OwnerName { get; set; }
public List<string> Pets { get; set; }
}
And the return type will be
IQueryable<PersonPet>
Your code should look like this :
IQueryable<PersonPet> query =
people.GroupJoin(pets,
person => person,
pet => pet.Owner,
(person, petCollection) =>
new PersonPet()
{
OwnerName = person.Name,
Pets = petCollection.Select(pet => pet.Name)
});
I can't test it so do some manipulation if it needs.