Consider we have these two entities and one custom object :
public class Entiy1
{
public int Id { get; set; }
public int DestinationId { get; set;
Here's a way to do it:
var query = from e1 in
(from e1 in entities1
group e1 by e1.DestinationId into grp
select grp.First())
join e2 in entities2 on e1.DestinationId equals e2.DestinationId
select new EntityDTO
{
DestinationId = e1.DestinationId,
DestinationName = e2.DestinationName,
Name = e1.Name,
JobTitle = e1.JobTitle
} ;
The trick is the group by
and then taking the first element of the grouping. This is also referred to as "distinct by" that a library like MoreLinq provides out of the box.