开发者

How to truncate table using Telerik OpenAccess ORM?

开发者 https://www.devze.com 2023-03-26 10:00 出处:网络
I\'ve tried to ObjectScope.GetSqlQuery(\"TRUNCATE TABLE %ta开发者_运维问答ble_name%\", null, null).Execute();

I've tried to

ObjectScope.GetSqlQuery("TRUNCATE TABLE %ta开发者_运维问答ble_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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消