Back to Devexpress

XPO Templates

coderushforroslyn-118557-coding-assistance-code-templates-xpo-templates.md

latest3.8 KB
Original Source

XPO Templates

  • Jan 31, 2023
  • 2 minutes to read

This topic describes templates you can use when you implement business classes in eXpress Persistent Objects ( XPO ).

Important

Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense , refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.

Member Declaration

XPO Persistent Class

Template: xc

csharp
public class PersistentClass : XPObject {
    public PersistentClass(Session session) : base(session) { }
}
vb
Public Class PersistentClass
    Inherits XPObject
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
End Class

XPO Persistent Property

Template: xp [1]

csharp
string propertyName;
[Size(SizeAttribute.DefaultStringMappingFieldSize)]
public string PropertyName {
    get => propertyName;
    set => SetPropertyValue(nameof(PropertyName), ref propertyName, value);
}
vb
Private _propertyName As String
<Size(SizeAttribute.DefaultStringMappingFieldSize)>
Property PropertyName As String
    Get
        Return _propertyName
    End Get
    Set(ByVal Value As String)
        SetPropertyValue(Nameof(PropertyName), _propertyName, Value)
    End Set
End Property

XPO-Associated Property

Template: xpa

csharp
object propertyName;
[Association("object-Programs")]
public object PropertyName {
    get => propertyName;
    set => SetPropertyValue(nameof(PropertyName), ref propertyName, value);
}
vb
Private _propertyName As Object
<Association("Object-Persons")> _
Property PropertyName() As Object
    Get
        Return _propertyName
    End Get
    Set(ByVal Value As Object)
        SetPropertyValue(Nameof(PropertyName), _propertyName, Value)
    End Set
End Property

XPO-Associated Collection

Template: xpcl

csharp
[Association("Program-Relations")]
public XPCollection<RelationType> Relations {
    get {
        return GetCollection<RelationType>(nameof(Relations));
    }
}
vb
<Association("Person-Relations")> 
Public ReadOnly Property Relations() As XPCollection(Of RelationType)
    Get
        Return GetCollection(Of RelationType)(NameOf(Relations))
    End Get
End Property

XPO Read-Only Persistent Property

Template: xr [2]

csharp
[Persistent(nameof(PropertyName))]
int propertyName;
[PersistentAlias(nameof(propertyName))]
public int PropertyName {
    get { return propertyName; }
}
vb
<Persistent(Nameof(PropertyName))> _
Private _propertyName As Integer

<PersistentAlias(Nameof(_propertyName))> _
ReadOnly Property PropertyName As Integer
    Get
        Return _propertyName
    End Get
End Property

Footnotes

  1. The xp template must be followed by a type mnemonic. For example, s for string.

  2. The xr template must be followed by a type mnemonic. For example, i for integer.

See Also

XAF Templates

Members Declaration

Custom Template Creation