using System;

namespace EmployeeComplexType
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new EFEmployeeEntities())
            {

                var name1 = new EmployeeName { FirstName = "John", MiddleName = "M", LastName = "Doe", Salutation = "Jr." };
                var name2 = new EmployeeName { FirstName = "Jane",MiddleName = "J", LastName = "Doe",Salutation = "Sir."};
                var address1 = new EmployeeAddress
                {
                    AddressLine1 = "123 Elm street",
                    AddressLine2 = "ABC",
                    City = "SanMateo",
                    State = "CA",
                    ZipCode = "94403"
                };

                var address2 = new EmployeeAddress
                {
                    AddressLine1 = "222 Baker St.",
                    AddressLine2 = "APT#777",
                    City = "St.Louis",
                    State = "MO",
                    ZipCode = "64133"
                };

                context.Employee.Add(new Employee { EmployeeName = name1, EmployeeAddress = address1 });
                context.Employee.Add(new Employee { EmployeeName = name2, EmployeeAddress = address2 });
                context.SaveChanges();
            }

            using (var context = new EFEmployeeEntities())
            {
                Console.WriteLine("Employee");
                foreach (var employee in context.Employee)
                {
                    Console.WriteLine("{0} {1}", employee.EmployeeName.FirstName, employee.EmployeeName.LastName);
                    Console.WriteLine("{0}", employee.EmployeeAddress.AddressLine1);
                    Console.WriteLine("{0}", employee.EmployeeAddress.AddressLine2);
                    Console.WriteLine("{0},{1} {2}", employee.EmployeeAddress.City, employee.EmployeeAddress.State, employee.EmployeeAddress.ZipCode);
                    Console.WriteLine();
                }
            }
        }
    }
}
