using System.Collections.Generic;
public static void Main()
List<RelationDTO> relationDTOList = new List<RelationDTO>
new RelationDTO { PersonId = 1, RelativeId = 2, Relation = "Son" },
new RelationDTO { PersonId = 2, RelativeId = 1, Relation = "Father" },
new RelationDTO { PersonId = 1, RelativeId = 3, Relation = "Mother" },
new RelationDTO { PersonId = 3, RelativeId = 1, Relation = "Son" },
new RelationDTO { PersonId = 2, RelativeId = 3, Relation = "Husband" },
new RelationDTO { PersonId = 3, RelativeId = 2, Relation = "Wife" },
var result = (from child in relationDTOList
join parent in relationDTOList on child.PersonId equals parent.RelativeId
PersonId = child.PersonId,
RelationId = child.RelativeId,
Relation = child.Relation,
ReverseRelation = parent.Relation
Console.WriteLine(g.PersonId);
Console.WriteLine(g.RelationId);
Console.WriteLine(g.Relation);
Console.WriteLine(g.ReverseRelation);
Console.WriteLine("------------------");
public int PersonId { get; set; }
public int RelativeId { get; set; }
public string Relation { get; set; }
public int PersonId { get; set; }
public int RelationId { get; set; }
public string Relation { get; set; }
public string ReverseRelation { get; set; }