AssociationAttribute Class
In This Article
Identifies the end of an association that is involved in an object relationship.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
#Declaration
#Remarks
Apply this attribute to both properties at the ends of the association, specifying an object relationship.
#Example
In the following sample code, the Location class might contain several Departments and each Department can in turn span several Locations.
using DevExpress.Xpo;
// ...
public class Location : XPObject {
public string Name {
get { return fName; }
set { SetPropertyValue(nameof(Name), ref fName, value); }
}
string fName;
[Association("Locations-Departments")]
public XPCollection<Department> Departments {
get { return GetCollection<Department>(nameof(Departments)); }
}
}
public class Department : XPObject {
public string Name {
get { return fName; }
set { SetPropertyValue(nameof(Name), ref fName, value); }
}
string fName;
[Association("Locations-Departments")]
public XPCollection<Location> Locations {
get { return GetCollection<Location>(nameof(Locations)); }
}
}
See Also