coderushforroslyn-118557-coding-assistance-code-templates-xpo-templates.md
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.
Template: xc
public class PersistentClass : XPObject {
public PersistentClass(Session session) : base(session) { }
}
Public Class PersistentClass
Inherits XPObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
End Class
Template: xp [1]
string propertyName;
[Size(SizeAttribute.DefaultStringMappingFieldSize)]
public string PropertyName {
get => propertyName;
set => SetPropertyValue(nameof(PropertyName), ref propertyName, value);
}
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
Template: xpa
object propertyName;
[Association("object-Programs")]
public object PropertyName {
get => propertyName;
set => SetPropertyValue(nameof(PropertyName), ref propertyName, value);
}
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
Template: xpcl
[Association("Program-Relations")]
public XPCollection<RelationType> Relations {
get {
return GetCollection<RelationType>(nameof(Relations));
}
}
<Association("Person-Relations")>
Public ReadOnly Property Relations() As XPCollection(Of RelationType)
Get
Return GetCollection(Of RelationType)(NameOf(Relations))
End Get
End Property
Template: xr [2]
[Persistent(nameof(PropertyName))]
int propertyName;
[PersistentAlias(nameof(propertyName))]
public int PropertyName {
get { return propertyName; }
}
<Persistent(Nameof(PropertyName))> _
Private _propertyName As Integer
<PersistentAlias(Nameof(_propertyName))> _
ReadOnly Property PropertyName As Integer
Get
Return _propertyName
End Get
End Property
Footnotes
The xp template must be followed by a type mnemonic. For example, s for string.
The xr template must be followed by a type mnemonic. For example, i for integer.
See Also