Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Generate Persistent Classes in a Single File Instead of Dividing to Partial Classes
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > Defining a Data Model > How to: Generate Persistent Classes in a Single File Instead of Dividing to Partial Classes

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.

When Reverse-Mapping a database OpenAccess generates persistent classes as partial divided into two files each. One is named ClassName.Telerik.OpenAccess.cs where the private fields are stored and the other ClassName.cs where properties for the fields in the other partial class are stored. If the classes are regenerated at some point, the ClassName.cs file will not be overwritten in order to preserve the user changes that might have been done. The new content of this file can be found in a commented block at the bottom of the ClassName.Telerik.OpenAccess.cs file and can be manually copied to the first file if necessary.

To have the code for one class in one file:

  1. In the Reverse-Mapping wizard click Options, which is the third button in the upper left corner.


  2. In the Options dialog, go to the Source Generation section.
  3. Set the Generate partial classes option to false.

The persistent classes generated after this step will have the following form:

C# Copy Code
[Telerik.OpenAccess.Persistent(IdentityField="categoryID")]
public class Category
{
   
private int categoryID; // pk
   
private string categoryName;
   
private string description;
   
private byte[] picture;

   
public Category()
   {
   }
   
   [Telerik.OpenAccess.FieldAlias(
"categoryID")]
   
public int CategoryID
   {
       get {
return categoryID; }
       set {
this.categoryID = value; }
   }

   [Telerik.OpenAccess.FieldAlias(
"categoryName")]
   
public string CategoryName
   {
       get {
return categoryName; }
       set {
this.categoryName = value; }
   }

   [Telerik.OpenAccess.FieldAlias(
"description")]
   
public string Description
   {
       get {
return description; }
       set {
this.description = value; }
   }

   [Telerik.OpenAccess.FieldAlias(
"picture")]
   
public byte[] Picture
   {
       get {
return picture; }
       set {
this.picture = value; }
   }
}

 

VB .NET Copy Code
<Telerik.OpenAccess.Persistent(IdentityField:="_categoryID")> _
Public Class Category
    Private Dim _categoryID As Integer 'pk
    Private Dim _categoryName As String
    Private Dim _description As String
    Private Dim _picture As Byte()

    Public Sub New()
    End Sub
    <Telerik.OpenAccess.FieldAlias("_categoryID")> _
    Public Property CategoryID() As Integer
        Get
            Return _categoryID
        End Get
        Set( ByVal Value As Integer )
            Me._categoryID = Value
        End Set
    End Property

    <Telerik.OpenAccess.FieldAlias("_categoryName")> _
    Public Property CategoryName() As String
        Get
            Return _categoryName
        End Get
        Set( ByVal Value As String )
            Me._categoryName = Value
        End Set
    End Property

    <Telerik.OpenAccess.FieldAlias("_description")> _
    Public Property Description() As String
        Get
            Return _description
        End Get
        Set( ByVal Value As String )
            Me._description = Value
        End Set
    End Property

    <Telerik.OpenAccess.FieldAlias("_picture")> _
    Public Property Picture() As Byte()
        Get
            Return _picture
        End Get
        Set( ByVal Value As Byte() )
            Me._picture = Value
        End Set
    End Property


End Class