/// <summary>
        /// Create a new Plumber object.
        /// </summary>
        /// <param name="tradesmanId">Initial value of the TradesmanId property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        /// <param name="isCertified">Initial value of the IsCertified property.</param>
        /// <param name="locationId">Initial value of the LocationId property.</param>
        public static Plumber CreatePlumber(global::System.Int32 tradesmanId, global::System.String name, global::System.Boolean isCertified, global::System.Int32 locationId)
        {
            Plumber plumber = new Plumber();

            plumber.TradesmanId = tradesmanId;

            plumber.Name = name;

            plumber.IsCertified = isCertified;

            plumber.LocationId = locationId;

            return(plumber);
        }
Пример #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();
        }