The simplest approach here is to fetch into an anonymous type and then do the rest in-process via AsEnumerable
:
return (from p in _db.P
join t in _db.TP on p.Id equals t.PId
select new { t.PId, t.Id }).AsEnumerable()
.Select(x => new TPE { PId = x.PId, TId = x.Id })
.ToList();
Or all in extension method syntax:
return _db.P.Join(_db.TP, p => p.Id, t => t.PId,
(p, t) => new { t.PId, t.Id })
.AsEnumerable()
.Select(x => new TPE { PId = x.PId, TId = x.Id })
.ToList();
Resources:https://stackoverflow.com/questions/7013189/linq-query-cant-select-data-into-a-custom-class-object