/// <summary> /// Create a new Foreman object. /// </summary> /// <param name="foremanId">Initial value of the ForemanId property.</param> /// <param name="locationId">Initial value of the LocationId property.</param> /// <param name="name">Initial value of the Name property.</param> public static Foreman CreateForeman(global::System.Int32 foremanId, global::System.Int32 locationId, global::System.String name) { Foreman foreman = new Foreman(); foreman.ForemanId = foremanId; foreman.LocationId = locationId; foreman.Name = name; return(foreman); }
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(); }
/// <summary> /// Deprecated Method for adding a new object to the Foremen EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToForemen(Foreman foreman) { base.AddObject("Foremen", foreman); }