Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Overview
Programmer's Guide > OpenAccess ORM Classic (Old API) > Development Environment > Wizards and Dialogs > Overview

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.

The process of having domain objects in your application scope that have to be persisted, but there is no database schema defined for them in advance, is called "Forward Mapping". A persistent class is one, which retains its field values after a program has terminated. When the program is run again, these objects can be retrieved and the data which they contain is again available. When creating a program, a declaration of persistence capable class types is required. This declaration is done by manually typing the [Persistent] attribute above each class definition or by using the Forward Mapping wizard. It is available in the OpenAccess menu after enabling the project to use OpenAccess.

Before using the Forward Mapping wizard you should enable your project to work with OpenAccess ORM.

The purpose of this section is to provide you with detail information about the Forward Mapping wizard. The following topics are included:

Before proceeding further with the topics from this section, you should create several helper classes used in the various demos:

  • Category
C# Copy Code
public class Category
{
   
private string name;
   
private string description;
   
//This Generic IList collection of Product
   
//references avoids casts in OQL-queries
   
//this relationship is bidirectional
   
private IList<Product> products;
   
//OpenAccess enhancer requires a no-args constructor
   
private Category()
   {
   }
   
public Category( string name )
   {
       
this.name = name;
   }
   
public string Name
   {
       get
       {
           
return name;
       }
       set
       {
           name = value;
       }
   }
   
public string Description
   {
       get
       {
           
return description;
       }
       set
       {
           description = value;
       }
   }
   
public IList<Product> Products
   {
       get
       {
           
if ( products == null )
           {
               products =
new List<Product>();
           }
           
return products;
       }
   }
   
public override string ToString()
   {
       
return name;
   }
}
VB.NET Copy Code
Public Class Category
    Private m_name As String
    Private m_description As String
    'This Generic IList collection of Product
    'references avoids casts in OQL-queries
    'this relationship is bidirectional
    Private m_products As IList(Of Product)
    'OpenAccess enhancer requires a no-args constructor
    Private Sub New()
    End Sub
    Public Sub New(ByVal name As String)
        Me.m_name = name
    End Sub
    Public Property Name() As String
        Get
            Return m_name
        End Get
        Set(ByVal value As String)
            m_name = value
        End Set
    End Property
    Public Property Description() As String
        Get
            Return m_description
        End Get
        Set(ByVal value As String)
            m_description = value
        End Set
    End Property
    Public ReadOnly Property Products() As IList(Of Product)
        Get
            If m_products Is Nothing Then
                m_products = New List(Of Product)()
            End If
            Return m_products
        End Get
    End Property
    Public Overloads Overrides Function ToString() As String
        Return m_name
    End Function
End Class
  • Product
C# Copy Code
public class Product
{
   
private int productNo;
   
private string name;
   
private float unitPrice;
   
private Supplier supplier;
   
//this relationship is bidirectional
   
private Category category;
   
//no-args constructor required by the Telerik.OpenAccess enhancer
   
public Product()
   {
   }
   
public Product( int productNo,
       
string name,
       
float unitPrice ) :
       
this( productNo, name, unitPrice, null )
   {
   }
   
public Product( int productNo,
                      
string name,
                      
float unitPrice,
                      Supplier supplier )
   {
       
this.productNo = productNo;
       
this.name = name;
       
this.unitPrice = unitPrice;
       
this.supplier = supplier;
   }
   
public int ProductNo
   {
       get
       {
           
return productNo;
       }
       set
       {
           productNo = value;
       }
   }
   
public string Name
   {
       get
       {
           
return name;
       }
       set
       {
           name = value;
       }
   }
   
public float UnitPrice
   {
       get
       {
           
return unitPrice;
       }
       set
       {
           unitPrice = value;
       }
   }
   
public Supplier Supplier
   {
       get
       {
           
return supplier;
       }
       set
       {
           supplier = value;
       }
   }
   
public Category Category
   {
       get
       {
           
return category;
       }
       set
       {
           
if ( category != null && category != value )
           {
               category.Products.Remove(
this );
           }
           category = value;
           
if ( category != null )
           {
               category.Products.Add(
this );
           }
       }
   }
   
public override string ToString()
   {
       
return name + " (" + productNo + ")";
   }
}
VB.NET Copy Code
Public Class Product
    Private m_productNo As Integer
    Private m_name As String
    Private m_unitPrice As Single
    Private m_supplier As Supplier
    'this relationship is bidirectional
    Private m_category As Category
    'no-args constructor required by the Telerik.OpenAccess enhancer
    Public Sub New()
    End Sub
    Public Sub New(ByVal productNo As Integer, ByVal name As String, ByVal unitPrice As Single)
        Me.New(productNo, name, unitPrice, Nothing)
    End Sub
    Public Sub New(ByVal productNo As Integer, ByVal name As String, ByVal unitPrice As Single, ByVal supplier As Supplier)
        Me.m_productNo = productNo
        Me.m_name = name
        Me.m_unitPrice = unitPrice
        Me.m_supplier = supplier
    End Sub
    Public Property ProductNo() As Integer
        Get
            Return m_productNo
        End Get
        Set(ByVal value As Integer)
            m_productNo = value
        End Set
    End Property
    Public Property Name() As String
        Get
            Return m_name
        End Get
        Set(ByVal value As String)
            m_name = value
        End Set
    End Property
    Public Property UnitPrice() As Single
        Get
            Return m_unitPrice
        End Get
        Set(ByVal value As Single)
            m_unitPrice = value
        End Set
    End Property
    Public Property Supplier() As Supplier
        Get
            Return m_supplier
        End Get
        Set(ByVal value As Supplier)
            m_supplier = value
        End Set
    End Property
    Public Property Category() As Category
        Get
            Return m_category
        End Get
        Set(ByVal value As Category)
            If m_category IsNot Nothing AndAlso m_category <> value Then
                m_category.Products.Remove(Me)
            End If
            m_category = value
            If m_category IsNot Nothing Then
                m_category.Products.Add(Me)
            End If
        End Set
    End Property
    Public Overloads Overrides Function ToString() As String
        Return (m_name & " (") + m_productNo & ")"
    End Function
End Class
  • Company
C# Copy Code
public class Company
{
   
private string name;
   
private IList<Address> addresses;
   
//Telerik.Telerik.Telerik.OpenAccess enhancer requires a no-args constructor
   
protected Company()
   {
   }
   
public Company( string name )
   {
       
this.name = name;
   }
   
public string Name
   {
       get
       {
           
return name;
       }
       set
       {
           name = value;
       }
   }
   
public IList<Address> Addresses
   {
       get
       {
           
if ( addresses == null )
           {
               addresses =
new List<Address>();
           }
           
return addresses;
       }
   }
   
public override string ToString()
   {
       
return name;
   }
}
VB.NET Copy Code
Public Class Company
    Private m_name As String
    Private m_addresses As IList(Of Address)
    'Telerik.Telerik.Telerik.OpenAccess enhancer requires a no-args constructor
    Protected Sub New()
    End Sub
    Public Sub New(ByVal name As String)
        Me.m_name = name
    End Sub
    Public Property Name() As String
        Get
            Return m_name
        End Get
        Set(ByVal value As String)
            m_name = value
        End Set
    End Property
    Public ReadOnly Property Addresses() As IList(Of Address)
        Get
            If m_addresses Is Nothing Then
                m_addresses = New List(Of Address)()
            End If
            Return m_addresses
        End Get
    End Property
    Public Overloads Overrides Function ToString() As String
        Return m_name
    End Function
End Class
  • Address
C# Copy Code
public class Address
{
   
private string street;
   
private int zip;
   
private string city;
   
public Address( string street, int zip, string city )
   {
       
this.street = street;
       
this.zip = zip;
       
this.city = city;
   }
   
public Address()
   {
   }
   
public string Street
   {
       get
       {
           
return street;
       }
       set
       {
           street = value;
       }
   }
   
public int Zip
   {
       get
       {
           
return zip;
       }
       set
       {
           zip = value;
       }
   }
   
public string City
   {
       get
       {
           
return city;
       }
       set
       {
           city = value;
       }
   }
   
public override string ToString()
   {
       
return street + ", " + zip + " " + city;
   }
}
VB.NET Copy Code
Public Class Address
    Private m_street As String
    Private m_zip As Integer
    Private m_city As String
    Public Sub New(ByVal street As String, ByVal zip As Integer, ByVal city As String)
        Me.m_street = street
        Me.m_zip = zip
        Me.m_city = city
    End Sub
    Public Sub New()
    End Sub
    Public Property Street() As String
        Get
            Return m_street
        End Get
        Set(ByVal value As String)
            m_street = value
        End Set
    End Property
    Public Property Zip() As Integer
        Get
            Return m_zip
        End Get
        Set(ByVal value As Integer)
            m_zip = value
        End Set
    End Property
    Public Property City() As String
        Get
            Return m_city
        End Get
        Set(ByVal value As String)
            m_city = value
        End Set
    End Property
    Public Overloads Overrides Function ToString() As String
        Return ((m_street & ", ") + m_zip & " ") + m_city
    End Function
End Class
  • Supplier
C# Copy Code
public class Supplier : Company
{
   
private int supplierNo;
   
private string homePage;
   
//no-args constructor required by the OpenAccess enhancer
   
private Supplier()
   {
   }
   
public Supplier( string name, int supplierNo )
       :
base( name )
   {
       
this.supplierNo = supplierNo;
   }
   
public Supplier( string name, int supplierNo, string homePage )
       :
base( name )
   {
       
this.supplierNo = supplierNo;
       
this.homePage = homePage;
   }
   
public int SupplierNo
   {
       get
       {
           
return supplierNo;
       }
   }
   
public string HomePage
   {
       get
       {
           
return homePage;
       }
       set
       {
           homePage = value;
       }
   }
}
VB.NET Copy Code
Public Class Supplier
    Inherits Company
    Private m_supplierNo As Integer
    Private m_homePage As String
    'no-args constructor required by the OpenAccess enhancer
    Private Sub New()
    End Sub
    Public Sub New(ByVal name As String, ByVal supplierNo As Integer)
        MyBase.New(name)
        Me.m_supplierNo = supplierNo
    End Sub
    Public Sub New(ByVal name As String, ByVal supplierNo As Integer, ByVal homePage As String)
        MyBase.New(name)
        Me.m_supplierNo = supplierNo
        Me.m_homePage = homePage
    End Sub
    Public ReadOnly Property SupplierNo() As Integer
        Get
            Return m_supplierNo
        End Get
    End Property
    Public Property HomePage() As String
        Get
            Return m_homePage
        End Get
        Set(ByVal value As String)
            m_homePage = value
        End Set
    End Property
End Class