.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

XPClassInfo.CreateMember(String, XPClassInfo, Boolean, Boolean, Attribute[]) Method

Creates a new member metadata which references the specified XPClassInfo object.

Namespace: DevExpress.Xpo.Metadata

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public XPCustomMemberInfo CreateMember(
    string propertyName,
    XPClassInfo referenceType,
    bool nonPersistent,
    bool nonPublic,
    params Attribute[] attributes
)
Public Function CreateMember(
    propertyName As String,
    referenceType As XPClassInfo,
    nonPersistent As Boolean,
    nonPublic As Boolean,
    ParamArray attributes As Attribute()
) As XPCustomMemberInfo
public XPCustomMemberInfo CreateMember(
    string propertyName,
    XPClassInfo referenceType,
    bool nonPersistent,
    bool nonPublic,
    params Attribute[] attributes
)
Public Function CreateMember(
    propertyName As String,
    referenceType As XPClassInfo,
    nonPersistent As Boolean,
    nonPublic As Boolean,
    ParamArray attributes As Attribute()
) As XPCustomMemberInfo

Parameters

Name Type Description
propertyName String

A String value which specifies the name of the new member.

referenceType XPClassInfo

An XPClassInfo object that provides the metadata of the class which the new property references.

nonPersistent Boolean

true if the new member is not persistent; otherwise, false.

nonPublic Boolean

true if the new member isn't public; otherwise, false.

attributes Attribute[]

An array of Attribute objects that represent the new member's attributes.

Parameters

Name Type Description
propertyName String

A String value which specifies the name of the new member.

referenceType XPClassInfo

An XPClassInfo object that provides the metadata of the class which the new property references.

nonPersistent Boolean

true if the new member is not persistent; otherwise, false.

nonPublic Boolean

true if the new member isn't public; otherwise, false.

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

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.

Examples

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));
customerClassInfo.CreateMember("Orders", typeof(XPCollection), true, 
    new AssociationAttribute("CustomerOrders", typeof(Order)), new AggregatedAttribute());
See Also