Пример #1
0
 protected DBUpdaterBase(string keyPropertyName)
 {
     RegisterEntitiesCore();
     updatingObjectSpaceProvider = CreateUpdatingObjectSpaceProvider();
     updatingObjectSpaceProvider.UpdateSchema();
     this.keyPropertyName = keyPropertyName;
 }
Пример #2
0
        public static void DeleteAllData(this IObjectSpaceProvider objectSpaceProvider)
        {
            using var objectSpace = objectSpaceProvider.CreateUpdatingObjectSpace(true);
            var dbConnection =
                ((ConnectionProviderSql)((BaseDataLayer)((XPObjectSpace)objectSpace).Session.DataLayer)
                 .ConnectionProvider).Connection;

            DeleteAllData(dbConnection);

            objectSpaceProvider.UpdateSchema();
        }
Пример #3
0
        public static void DeleteAllData(this IObjectSpaceProvider objectSpaceProvider)
        {
            using (var objectSpace = objectSpaceProvider.CreateUpdatingObjectSpace(true)){
                var dbConnection = ((ConnectionProviderSql)((BaseDataLayer)((XPObjectSpace)objectSpace).Session.DataLayer).ConnectionProvider).Connection;
                using (var dbCommand = dbConnection.CreateCommand()){
                    dbCommand.CommandText = @"
        EXEC sp_MSForEachTable ""ALTER TABLE ? NOCHECK CONSTRAINT all""
        EXEC sp_MSForEachTable ""DELETE FROM ?""
        exec sp_MSForEachTable ""ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all""
";
                    dbCommand.ExecuteNonQuery();
                }
                objectSpaceProvider.UpdateSchema();
            }
        }