using System.Collections.Generic;
public static void Main()
IList<Child> childList = new List<Child>() {
new Child() { Id = 100, Name = "John" } ,
new Child() { Id = 200, Name = "Steve"} ,
new Child() { Id = 300, Name = "Bill" } ,
new Child() { Id = 400, Name = "Ram" } ,
new Child() { Id = 500, Name = "Ron" }
IList<Parent> parentList = new List<Parent>() {
new Parent() { Id = 111, UserId = 1 } ,
new Parent() { Id = 222, UserId = 2} ,
new Parent() { Id = 333, UserId = 3 } ,
new Parent() { Id = 444, UserId = 4 } ,
new Parent() { Id = 555, UserId = 5 }
IList<ParentChild> parentChildList = new List<ParentChild>() {
new ParentChild() {Id = 0, ParentId = 111, ChildId = 100 },
new ParentChild() {Id = 1, ParentId = 111, ChildId =200 },
new ParentChild() {Id = 2, ParentId = 111, ChildId =300 },
new ParentChild() {Id = 3, ParentId = 111, ChildId =400 },
new ParentChild() {Id = 4, ParentId = 111, ChildId = 500 },
new ParentChild() {Id = 5, ParentId = 444, ChildId = 200 },
new ParentChild() {Id = 6, ParentId = 444, ChildId = 300 },
new ParentChild() {Id = 7, ParentId = 444, ChildId = 400 },
new ParentChild() {Id = 8, ParentId = 444, ChildId = 500 },
new ParentChild() {Id = 9, ParentId = 333, ChildId = 100 },
new ParentChild() {Id = 10, ParentId = 333, ChildId = 200 },
new ParentChild() {Id = 11, ParentId = 333, ChildId = 300 },
new ParentChild() {Id = 12, ParentId = 222, ChildId = 200 },
new ParentChild() {Id = 13, ParentId = 222, ChildId = 400 },
new ParentChild() {Id = 14, ParentId = 555, ChildId = 500 },
var parentChildGroup = from parent in parentList
join parentChild in parentChildList on parent.Id equals parentChild.ParentId
join child in childList on parentChild.ChildId equals child.Id
group child by child.Id into newGroup
foreach (var item in parentChildGroup)
foreach(var child in item.Children)
Console.WriteLine(child.Id + ", " + child.Name);
public int Id { get; set; }
public int UserId { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public class ParentChild {
public int Id { get; set; }
public int ParentId { get; set; }
public int ChildId { get; set; }