private void CopyDrivers(Quote oldQuote, int newQuoteId) { var db = new QuotesDBEntities(); var driverList = db.Drivers.Select(d => d).Where(d => d.QuoteID == oldQuote.ID); foreach (var oldDriver in driverList) { var newDriver = new Driver { FirstName = oldDriver.FirstName, LastName = oldDriver.LastName, Ssn = oldDriver.Ssn, DateOfBirth = oldDriver.DateOfBirth, DriverLicenseNumber = oldDriver.DriverLicenseNumber, DLState = oldDriver.DLState, SafeDrivingSchool = oldDriver.SafeDrivingSchool, QuoteID = newQuoteId }; db.Drivers.AddObject(newDriver); } db.SaveChanges(); }
/// <summary> /// Deprecated Method for adding a new object to the Drivers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDrivers(Driver driver) { base.AddObject("Drivers", driver); }
/// <summary> /// Create a new Driver object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="dateOfBirth">Initial value of the DateOfBirth property.</param> /// <param name="driverLicenseNumber">Initial value of the DriverLicenseNumber property.</param> /// <param name="dLState">Initial value of the DLState property.</param> /// <param name="safeDrivingSchool">Initial value of the SafeDrivingSchool property.</param> /// <param name="quoteID">Initial value of the QuoteID property.</param> public static Driver CreateDriver(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.DateTime dateOfBirth, global::System.String driverLicenseNumber, global::System.Int32 dLState, global::System.Boolean safeDrivingSchool, global::System.Int32 quoteID) { Driver driver = new Driver(); driver.ID = id; driver.FirstName = firstName; driver.LastName = lastName; driver.DateOfBirth = dateOfBirth; driver.DriverLicenseNumber = driverLicenseNumber; driver.DLState = dLState; driver.SafeDrivingSchool = safeDrivingSchool; driver.QuoteID = quoteID; return driver; }