static void ClearData(Xy.Data.DataBase db) { db.Open(); db.StartTransaction(); List<Xy.Data.Procedure> deleteProcess = new List<Xy.Data.Procedure>(); deleteProcess.Add(new Xy.Data.Procedure("DeleteUserExtra", @"delete from [UserExtra];")); deleteProcess.Add(new Xy.Data.Procedure("DeleteUser", @"delete from [User]; DBCC CHECKIDENT ('User', RESEED, 0);")); deleteProcess.Add(new Xy.Data.Procedure("DeletePowerList", @"delete from [PowerList]; DBCC CHECKIDENT ('PowerList', RESEED, 0);delete from [PowerShip]; DBCC CHECKIDENT ('PowerShip', RESEED, 0);")); deleteProcess.Add(new Xy.Data.Procedure("DeleteUserGroup", @"delete from [UserGroup]; DBCC CHECKIDENT ('UserGroup', RESEED, 0);")); deleteProcess.Add(new Xy.Data.Procedure("DeleteInstallation", @"delete from [Installation]; DBCC CHECKIDENT ('Installation', RESEED, 0);")); //deleteProcess.Add(new Xy.Data.Procedure("deletePostType", @"delete from [PostType]; DBCC CHECKIDENT ('PostType', RESEED, 0);delete from [PostAttribute]; DBCC CHECKIDENT ('PostAttribute', RESEED, 0);")); try { Console.WriteLine("\tDelete Data"); foreach (Xy.Data.Procedure _item in deleteProcess) { Console.WriteLine("\t" + _item.Name); _item.InvokeProcedure(db); } db.CommitTransaction(); } catch(Exception ex) { db.RollbackTransation(); } finally { db.Close(); } }