// 用于 CUD 重写示例 partial void InsertRegion(Region instance) { // 此分部方法将调用 ExecuteDynamicInsert 来插入 Region 实例。 // 如果不调用 ExecuteDynameicInsert 方法,还可以在此处调用存储过程 // 接受参数,并将某个实例插入该表中。 Console.WriteLine("***** Executing InsertRegion Override ******"); Console.WriteLine("Calling up ExecuteDynamicInsert on a Region instance"); this.ExecuteDynamicInsert(instance); }
// For CUD Override Sample partial void InsertRegion(Region instance) { // This partial method is calling ExecuteDynamicInsert to insert the Region instance. // Instead of the ExecuteDynameicInsert method, a stored procedure could be called // here to take in parameters and insert a instance to the table . Console.WriteLine("***** Executing InsertRegion Override ******"); Console.WriteLine("Calling up ExecuteDynamicInsert on a Region instance"); this.ExecuteDynamicInsert(instance); }
partial void DeleteRegion(Region instance);
partial void UpdateRegion(Region instance);
partial void InsertRegion(Region instance);
public void LinqToSqlInsert09() { Console.WriteLine("*** BEFORE ***"); ObjectDumper.Write(from c in db.Regions where c.RegionID == 32 select c); Console.WriteLine(); Console.WriteLine("*** INSERT OVERRIDE ***"); //Beverages Region nwRegion = new Region() { RegionID = 32, RegionDescription = "Rainy" }; db.Regions.InsertOnSubmit(nwRegion); db.SubmitChanges(); Console.WriteLine(); Console.WriteLine("*** AFTER ***"); ClearDBCache(); ObjectDumper.Write(from c in db.Regions where c.RegionID == 32 select c); CleanupInsert09(); // Restore previous database state }
public void G12_EmptyInsertList() { Northwind db = CreateDB(); Region newRegion = new Region() { RegionDescription = "" }; // RegionDescription must be non-null db.Regions.InsertOnSubmit(newRegion); db.SubmitChanges(); Assert.IsNotNull(newRegion.RegionID); db.Regions.DeleteOnSubmit(newRegion); db.SubmitChanges(); }