/// <summary>
        /// Create a new JobSite object.
        /// </summary>
        /// <param name="locationId">Initial value of the LocationId property.</param>
        /// <param name="address">Initial value of the Address property.</param>
        /// <param name="city">Initial value of the City property.</param>
        /// <param name="state">Initial value of the State property.</param>
        /// <param name="zIPCode">Initial value of the ZIPCode property.</param>
        /// <param name="phoneId">Initial value of the PhoneId property.</param>
        /// <param name="jobSiteName">Initial value of the JobSiteName property.</param>
        public static JobSite CreateJobSite(global::System.Int32 locationId, global::System.String address, global::System.String city, global::System.String state, global::System.String zIPCode, global::System.Int32 phoneId, global::System.String jobSiteName)
        {
            JobSite jobSite = new JobSite();

            jobSite.LocationId = locationId;

            jobSite.Address = address;

            jobSite.City = city;

            jobSite.State = state;

            jobSite.ZIPCode = zIPCode;

            jobSite.PhoneId = phoneId;

            jobSite.JobSiteName = jobSiteName;

            return(jobSite);
        }
예제 #2
0
        static void RunExample()
        {
            using (var context = new EFRecipesEntities())
            {
                var foreman1 = new Foreman {
                    Name = "Carl Ramsey"
                };
                var foreman2 = new Foreman {
                    Name = "Nancy Ortega"
                };
                var phone = new Phone {
                    Number = "817 867-5309"
                };
                var jobsite = new JobSite {
                    JobSiteName = "City Arena", Address = "123 Main", City = "Anytown", State = "TX", ZIPCode = "76082", Phone = phone
                };
                jobsite.Foremen.Add(foreman1);
                jobsite.Foremen.Add(foreman2);
                var plumber = new Plumber {
                    Name = "Jill Nichols", Email = "*****@*****.**", JobSite = jobsite
                };
                context.Tradesmen.AddObject(plumber);
                context.SaveChanges();
            }

            using (var context = new EFRecipesEntities())
            {
                var plumber = context.Tradesmen.OfType <Plumber>().Include("JobSite.Phone").Include("JobSite.Foremen").First();
                Console.WriteLine("Plumber's Name: {0} ({1})", plumber.Name, plumber.Email);
                Console.WriteLine("Job Site: {0}", plumber.JobSite.JobSiteName);
                Console.WriteLine("Job Site Phone: {0}", plumber.JobSite.Phone.Number);
                Console.WriteLine("Job Site Foremen:");
                foreach (var boss in plumber.JobSite.Foremen)
                {
                    Console.WriteLine("\t{0}", boss.Name);
                }
            }

            Console.WriteLine("Press <enter> to continue...");
            Console.ReadLine();
        }