In this video Mohammad Azam demonstrate the use of JOINS in LINQ Framework.

In this video Mohammad Azam demonstrate the use of JOINS in LINQ Framework.

static void Main(string[] args)
        {
            List<Person> persons = new List<Person>()
            { new Person() { FirstName="john", LastName="doe", PersonId = 1 },
                new Person() { FirstName="mary", LastName="kate", PersonId = 2 },
                new Person() { FirstName = "alex", LastName="lowe", PersonId = 3 }
            };

            List<Address> addresses = new List<Address>()
            { new Address { Person = persons[0], Street="street1", AddressId =1 },
                new Address { Person = persons[1], Street = "street2", AddressId =2 },
                new Address { Person = persons[1], Street = "street3", AddressId = 3 },
                new Address { Person = persons[0], Street = "street4", AddressId = 4},
                new Address { Person = persons[0], Street = "street5" , AddressId = 5 }
            };


            var list = from person in persons
                       join address in addresses
                       on person.PersonId equals address.Person.PersonId
                       select new { FirstName = person.FirstName, LastName = person.LastName };

            foreach (var item in list)
            {
                Console.WriteLine(item.FirstName + " " + item.LastName);
            }
                 
       
        }