开发者

How to truncate table using Telerik OpenAccess ORM?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜