XPClassInfo.CreateMember(String, XPClassInfo, Attribute[]) Method
Creates a new member metadata which is referenced to the specified XPClassInfo object.
Namespace: DevExpress.Xpo.Metadata
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
NuGet Package: DevExpress.Xpo
Declaration
Parameters
Name | Type | Description |
---|---|---|
propertyName | String | A String value which specifies the name of the new member. |
referenceType | XPClassInfo | An XPClassInfo object which provides the metadata of the class that the new property references. |
attributes | Attribute[] | An array of Attribute objects that represent the new member’s attributes. |
Returns
Type | Description |
---|---|
XPCustomMemberInfo | An XPCustomMemberInfo descendant which provides the new member’s metadata. |
Remarks
The CreateMember method allows custom members to be created dynamically.
Example
The following sample code shows how to create custom fields using the XPClassInfo.CreateMember method.
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
// ...
XPClassInfo customerClassInfo = Session.DefaultSession.GetClassInfo(typeof(Customer));
customerClassInfo.CreateMember("Name", typeof(string));
customerClassInfo.CreateMember("CompanyName", typeof(string));
// Set the nonPersistent parameter to true for collection properties
customerClassInfo.CreateMember("Orders", typeof(XPCollection), true,
new AssociationAttribute("CustomerOrders", typeof(Order)), new AggregatedAttribute());
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateMember(String, XPClassInfo, Attribute[]) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.