Consider the following code.
City and CitPlace are joined by CityCode.
What I want to do is perform a LEFT OUTER JOIN between CityPlace and City.
City[] cities = new City[]{
new City{CityCode="0771",CityName="Raipur",CityPopulation="BIG"},
new City{CityCode="0751",CityName="Gwalior",CityPopulation="MEDIUM"},
new City{CityCode="0755",CityName="Bhopal",CityPopulation="BIG"},
new City{CityCode="022",CityName="Mumbai",CityPopulation="BIG"},
};
CityPlace[] places = new CityPlace[]{
new CityPlace{CityCode="0771",Place="Shankar Nagar"},
new CityPlace{CityCode="0771",Place="Pandari"},
new CityPlace{CityCode="0771",Place="Energy Park"},
new CityPlace{CityCode="0751",Place="Baadaa"},
new CityPlace{CityCode="0751",Place="Nai Sadak"},
new CityPlace{CityCode="0751",Place="Jayendraganj"},
new CityPlace{CityCode="0751",Place="Vinay Nagar"},
new CityPlace{CityCode="0755",Place="Idgah Hills"},
new CityPlace{CityCode="022",Place="Parel"},
new CityPlace{CityCode="022",Place="Haaji Ali"},
new CityPlace{CityCode="022",Place="Girgaon Beach"},
new CityPlace{CityCode="0783",Place="Railway Station"}};
What I did is
var res = places.GroupJoin(cities,
p1=>p1.CityCode,
c1=>c1.CityCode,
(p2,c2s)=>new {Place=p2.Place,
CityName=c2s.Count()==0 ? "NO NAME"
: c2s.First().CityName });
foreach(var v in res)
Console.WriteLine(v);
Is this the standard or it is quicky and dirty solution?