First we define a data model as an interface:
public interface IDataModel
    {
        string StringValue { get; set; }
    }

Then, we initialize an IOG context with defined data model:
Context ctx = new Context(typeof(IDataModel));

Let's write some data to the data model:
// Open workspace for writing
using (var workspace = ctx.OpenWorkspace<IDataModel>(IsolationLevel.Exclusive))
{
  // Access the data model via the current workspace
  IDataModel data = workspace.Data;
  // Set the value in data model
  data.StringValue = "Hello world!";
  // Commit the change
  workspace.Commit();
}

Finally, read the data and write the message to console:
// Open workspace for reading
using (var workspace = ctx.OpenWorkspace<IDataModel>(IsolationLevel.ReadOnly))
{
  // Access the data model via the current workspace
  IDataModel data = workspace.Data;
  // Display the message
  Console.Write(data.StringValue);
}


Full source code for this example can be found in Execom.IOG.HelloWorld project in project source code.

Last edited Mar 14, 2012 at 10:15 AM by nenadsabo, version 2

Comments

No comments yet.