I have created a custom SOE which receives some data in JSON format and should create new features in an Oracle DB. A service is published with sources pointing to "SDE.DEFAULT" version. There is another version, already created - "SOS.ORDER1" (with parent "SDE.DEFAULT"). My SOE logic should create those new features in version "SOS.ORDER1".
I'm using this topic - Editing with the geodatabase API (Connecting to one version and editing another) to develop my logic, but when trying to create new features in a table I'm getting following error: Objects in this class cannot be updated outside an edit session [GDO.O_LINKA].
This is my workflow:
IWorkspace workspace = ... // from SOE
// workspace.ConnectionProperties.GetProperty("VERSION") => "SDE.DEFAULT"
// get a reference to the desired geodatabase version
IVersion version = (workspace as IVersionedWorkspace).FindVersion("SOS.ORDER1");
// this should start an editing session in SOS.ORDER1 version
IMultiuserWorkspaceEdit multiuserWorkspaceEdit = version as IMultiuserWorkspaceEdit;
IWorkspaceEdit2 workspaceEdit = version as IWorkspaceEdit2;
// start editing
// this probably still points to SDE.DEFAULT instead of SOS.ORDER1
ITable table = (workspace as IFeatureWorkspace).OpenTable("GDO.O_LINKA");
// error is thrown here
IRow row = table.CreateRow();
Is there something wrong with this code? After finding the desired geodatabase version and casting it to IMultiuserWorkspaceEdit, workspace still points to "SDE.DEFAULT". How can I properly update the sources to the new version or get a reference to its workspace?
I cannot publish a map service with sources pointing to "SOS.ORDER1" and make the edits directly there as there will be many versions, similar to SOS.ORDER1, created programmatically.