partial void DeleteTerritory(Territory instance);
public void LinqToSqlInsert03() { Northwind db = CreateDB(); var ds = new DataLoadOptions(); ds.LoadWith<Employee>(p => p.EmployeeTerritories); ds.LoadWith<EmployeeTerritory>(p => p.Territory); db.LoadOptions = ds; var q = from e in db.Employees where e.FirstName == "Nancy" select e; if (db.Employees.Any(e => e.FirstName == "Test Kira" && e.LastName == "Test Smith")) Assert.Ignore(); var newEmployee = new Employee { FirstName = "Test Kira", LastName = "Test Smith" }; var newTerritory = new Territory { TerritoryID = "12345", TerritoryDescription = "Test Anytown", Region = db.Regions.First() }; var newEmployeeTerritory = new EmployeeTerritory { Employee = newEmployee, Territory = newTerritory }; db.Employees.InsertOnSubmit(newEmployee); db.Territories.InsertOnSubmit(newTerritory); db.EmployeeTerritories.InsertOnSubmit(newEmployeeTerritory); db.SubmitChanges(); // cleanup db.EmployeeTerritories.DeleteOnSubmit(newEmployeeTerritory); db.Territories.DeleteOnSubmit(newTerritory); db.Employees.DeleteOnSubmit(newEmployee); db.SubmitChanges(); }
partial void InsertTerritory(Territory instance);
partial void UpdateTerritory(Territory instance);
private void detach_Territories(Territory entity) { this.SendPropertyChanging(); entity.Region = null; }
public void LinqToSqlInsert03() { Northwind db2 = new Northwind(connString); DataLoadOptions ds = new DataLoadOptions(); ds.LoadWith<nwind.Employee>(p => p.EmployeeTerritories); ds.LoadWith<nwind.EmployeeTerritory>(p => p.Territory); db2.LoadOptions = ds; var q = ( from e in db.Employees where e.FirstName == "Nancy" select e); Console.WriteLine("*** BEFORE ***"); ObjectDumper.Write(q, 1); Console.WriteLine(); Console.WriteLine("*** INSERT ***"); var newEmployee = new Employee { FirstName = "Kira", LastName = "Smith" }; var newTerritory = new Territory { TerritoryID = "12345", TerritoryDescription = "Anytown", Region = db.Regions.First() }; var newEmployeeTerritory = new EmployeeTerritory { Employee = newEmployee, Territory = newTerritory }; db.Employees.InsertOnSubmit(newEmployee); db.Territories.InsertOnSubmit(newTerritory); db.EmployeeTerritories.InsertOnSubmit(newEmployeeTerritory); db.SubmitChanges(); Console.WriteLine(); Console.WriteLine("*** AFTER ***"); ObjectDumper.Write(q, 2); Cleanup66(); // Restore previous database state }
public void Territories_Detach(Territory entity) { entity.Region = null; }
public void Territories_Attach(Territory entity) { entity.Region = this; }
private void Territories_Attach(Territory entity) { this.SendPropertyChanging(); entity.Region = this; }