Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Implement an IDataObjectKey
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > Working with Objects > How to: Implement an IDataObjectKey

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

To track successfully concurrency issues of any kind outside Telerik OpenAccess ORM, we need to accurately track which persistent class and its properties are modified. One way to do it is to have the Id and Version fields of the persistent class exposed publicly so that they can be accessed by customer bossiness logic or bind to UI controls. This is the purpose of the IDataObjectKey interface.

This is a sample that demonstrates how the interface is implemented:

C# Copy Code
[Persistent]
class Person : IDataObjectKey
{
   
public string DataObjectKey
   {
       get {
return Telerik.OpenAccess.DataObjectKey.Obtain(this); }
   }
   
private string name;
   
public string Name
   {
       get {
return name; }
       set { name = value; }
   }
}
VB.NET Copy Code
Imports Telerik.OpenAccess
Public Class Class1
End Class
<Persistent()> _
Class Person
    Implements IDataObjectKey
    Public ReadOnly Property DataObjectKey() As String Implements IDataObjectKey.DataObjectKey
        Get
            Return Telerik.OpenAccess.DataObjectKey.Obtain(Me)
        End Get
    End Property
    Private name1 As String
    Public Property Name() As String
        Get
            Return Name
        End Get
        Set(ByVal value As String)
            name1 = value
        End Set
    End Property
End Class

 

This functionality is helpful especially in web UI scenarios where you have a fully disconnected architecture. You can use this interface to preserve to which persistent class the modified data belongs, for example by storing the id and version fields in the viewstate.