Can you explain why example #1 fails with "No Translation to SQL" and example #2 works fine?
All in Repository:
EX#1:
public DomainPerson GetBestPerson()
{
var person= GetPeople().Where(p=>p.Quality=="Best").SingleOrDefault();
return person;
}
public IQueryable<DomainPerson> GetPeople()
{
var people= from p in Data.Persons
select MapToDomain(p);
return people;
}
private DomainPerson MapToDomain(Data.Person dataPerson)
{
DomainPerson domainPerson= new DomainPerson{
Id=dataPerson.Id,
Name=dataPerson.Name,
Quality=dataPerson.Quality,
};
return domainPerson;
}
EX#2
public DomainPerson GetBestPerson()
{
var person= GetPeople().Where(p=>p.Quality=="Best").SingleOrDefault();
return person;
}
public IQueryable<DomainPerson> GetPeople()
{
var people= from p in Data.Persons
select new DomainPerson{
Id=dataPerson.Id,
Name=dataPerson.Name,
Quality=dataPerson.Quality,
};
return people;
}