You are not logged in.
Pages: 1
I have been looking into updating our existing application to mORMot 2 and have a question about turning off the auto ID on a certain table.
I created a test application which is connecting to my SQL server fine using a TSQLRestServerDB. My question is about accessing the TRestStorageExternal.Instance.
I came up with this and it doesn't throw any errors but am wondering if this is the correct way of coding this. In my existing application I would just pass in the TSQLRestServerDB, but now it is needing a TRestOrmServer.
MyServer := TSQLRestServerDB.Create(Model,':memory:');
MyServer.CreateMissingTables;
MyServer.AcquireExecutionMode[execORMGet] := amBackgroundORMSharedThread;
MyServer.AcquireExecutionMode[execORMWrite] := amBackgroundORMSharedThread;
MyServer.DB.UseCache := false;
VStorage := TRestStorageExternal.Instance(TSQLUser, TRestOrmServer(MyServer.Server));
if Assigned(VStorage) then
begin
VStorage.EngineAddForcedID := -1;
end;
Thanks for any help
Offline
Instead of hard-coding the typecast, via TRestOrmServer(MyServer.Server), it is always safer to make an explicit cast like " (MyServer.Server as TRestOrmServer) ".
If there is a class type mismatch an explicit error will be raised at runtime. And since you do it once at startup, there is no performance penalty.
Better safe than sorry.
About your exact question, between mORMot 1 and mORMot 2, the EngineAddForcedID property behavior did not change.
Only its location did change.
Offline
Thanks, this resolves my worries and I can move on with my updating.
Offline
Pages: 1