I'm trying to write the following query in LINQ, but can't seem to get it correct.
select p.*
from Person p
inner join PersoniPhones i ON p.PersonID = i.PersonID
where p.PersonID in
(
SELECT PersonID
FROM
(
SELECT Top 10 PersonID, iPhoneID
FROM iPhone
ORDER BY LastPlayedDate DESC
) as t
)
I've tried the following, but it doesn't return correctly
var tenIPhones = from phone in context.PersonIPhones
.OrderByDescending(i => i.LastPlayedDate)
.Take(10)
select new { phone.PersonID, phone.IPHoneID};
var people = from p in context.Person
join t in tenIPhones on p.PersonID equals t.PersonID
select p;
Any ideas?