CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
var items = new List<Item> ();
var people = new List<Person> ();
var countries = new List<Country> ();
var continents = new List<Continent> ();
var brands = new List<Brand> ();
var itemsOwner =
items
.Join (people, src => src.OwnerId, p => p.PersonId, (src, p) => new { Item = src, Person = p })
.Join (brands, src => src.Item.BrandId, b => b.BrandId, (src, b) => new { src.Item, src.Person, Brand = b })
.Join (countries, src => src.Person.CountryId, c => c.CountryId, (src, c) => new { src.Item, src.Person, src.Brand, Country = c })
.Select (x => new { x.Item.ItemName, x.Person.PersonName, x.Brand.BrandName, x.Country.CountryName });
}
}
class Item
{
public string ItemName { get; set; }
public int OwnerId { get; set; }
public int BrandId { get; set; }
}
class Brand
{
public int BrandId { get; set; }
public string BrandName { get; set; }
}
class Person
{
public int PersonId { get; set; }
public string PersonName { get; set; }
public int CountryId { get; set; }
}
class Country
{
public int CountryId { get; set; }
public int CountryName { get; set; }
public int ContinentId { get; set; }
}
class Continent
{
public int ContinentId { get; set; }
public int ContinentName { get; set; }
}