XPO and XAF Templates

  • 3 minutes to read

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

Member declaration

XPO persistent class

Template: xc

public class PersistentClass : XPObject {
    public PersistentClass(Session session) : base(session) { }
}

XPO persistent property

Template: xp*

* This template must be followed by a type mnemonic. For details, refer to the Members Declaration article. xps (string) template.

string propertyName;
[Size(SizeAttribute.DefaultStringMappingFieldSize)]
public string PropertyName {
    get => propertyName;
    set => SetPropertyValue(nameof(PropertyName), ref propertyName, value);
}

XPO-associated property

Template: xpa

object propertyName;
[Association("object-Programs")]
public object PropertyName {
    get => propertyName;
    set => SetPropertyValue(nameof(PropertyName), ref propertyName, value);
}

XPO-associated collection

Template: xpcl

[Association("Program-Relations")]
public XPCollection<RelationType> Relations {
    get {
        return GetCollection<RelationType>(nameof(Relations));
    }
}

XPO read-only persistent property

Template: xr*

* This template must be followed by a type mnemonic. For details, refer to the Members Declaration article. xri (Integer) template.

[Persistent(nameof(PropertyName))]
int propertyName;
[PersistentAlias(nameof(propertyName))]
public int PropertyName {
    get { return propertyName; }
}

XPO Types

CodeRush includes XPO type mnemonics you can use in member declaration templates.

Type Mnemonic
DevExpress.Data.Filtering.AggregateOperand xao
DevExpress.Data.Filtering.BetweenOperator xbwo
DevExpress.Data.Filtering.BinaryOperator xbo
DevExpress.Data.Filtering.FunctionOperator xfo
DevExpress.Data.Filtering.GroupOperator xgo
DevExpress.Data.Filtering.InOperator xio
DevExpress.Data.Filtering.UnaryOperator xuo
DevExpress.Xpo.Session xss
DevExpress.Xpo.UnitOfWork xu
DevExpress.Xpo.XPCollection xcl

For instance, you can use the p template with the xss mnemonic (the pxss template) to declare a DevExpress.Xpo.Session type property.

DevExpress.Xpo.Session propertyName;

public DevExpress.Xpo.Session PropertyName {
    get { return propertyName; }
    set {
        propertyName = value;
    }
}

Expand a Template Instead of Visual Studio IntelliSense

The Visual Studio IntelliSense has priority over CodeRush templates. IntelliSense prevents the Space or Tab key from expanding templates because this key confirms the IntelliSense suggestion.

Press Esc to close the IntelliSense suggestions window and then press Space to expand a CodeRush template.

Dependent Namespace Templates

You can also enable the "Always expand templates" option on the IDE | IntelliSense options page to prioritize CodeRush template over Visual Studio IntelliSense.

Expand Templates

See Also