1

I've tried to

ObjectScope.GetSqlQuery("TRUNCATE TABLE %table_name%", null, null).Execute();

and

ObjectScope.GetOqlQuery("TRUNCATE TABLE %ClassName%Extent").Execute();

The first row does nothing. And the second throw Exception:

line 1:10: unexpected token: ["TABLE",<42>,line=1,col=10]
Original Query: TRUNCATE TABLE DayExtent
Enlightened
  • 239
  • 2
  • 13

1 Answers1

1

The method ExecuteDDLScript doesn't make a difference between DDL and DML script. It only requires that there are no open object scopes.

        IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();
        //do something here
        scope.Dispose();
        string tableToTruncate = "SOME_TABLE";
        scope.Database.GetSchemaHandler().ExecuteDDLScript(string.Format("TRUNCATE TABLE {0}", tableToTruncate));
        scope = ObjectScopeProvider1.GetNewObjectScope();
        //do something again

Hope that helps.

Nikola Kolev
  • 1,239
  • 3
  • 17
  • 25