using System.Text.RegularExpressions;
using System.Collections.Generic;
public static void Main()
List<Pond> ponds = new List<Pond>(){
new Pond() {PondID = 1, OwnerName = "Ehsan" },
new Pond() {PondID = 2, OwnerName = "Ahsan" },
new Pond() {PondID = 3, OwnerName = "ShahZeb" }
List<Fish> fishes = new List<Fish>(){
new Fish() {PondID = 1, FishName = "Star Fish" },
new Fish() {PondID = 1, FishName = "Shark" },
new Fish() {PondID = 2, FishName = "Star Fish" },
new Fish() {PondID = 2, FishName = "Shark" },
new Fish() {PondID = 3, FishName = "Dolphin" },
new Fish() {PondID = 3, FishName = "Jelly Fish" }
var result = from p in ponds
join f in fishes on p.PondID equals f.PondID
group f by new { f.PondID,p.OwnerName } into g
select new { Owner = g.Key.OwnerName, Fishes = String.Join(",",g.Select(x=>x.FishName))};
foreach(var item in result)
Console.WriteLine(String.Format("Owner : {0} and Fishses : {1}",item.Owner,item.Fishes));
public int PondID {get;set;}
public string OwnerName {get;set;}
public int PondID {get;set;}
public string FishName {get;set;}