Obfuscated Scenario: A person has zero, one or many pets.
Using Linq to Sql, the need is to get an IQueryable
list of pets for the given pe
Look at your query:
var personPets= from p in Person
where p.ID == somePersonID
select p.Pets;
What is happening is that you are returning an IEnumerable (of one element) of IEntitySet
types (the type: IEnumerable
).
You should get an IEnumerable
and it will be converted to IQueryable
by the AsQueryable
method:
public IQueryable GetPersonPets(int personID)
{
var person = Person.Single(p=> p.ID == personID);
return person.Pets.AsQueryable();
}