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

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

Creates a new member metadata.

Namespace: DevExpress.Xpo.Metadata

Assembly: DevExpress.Xpo.v20.2.dll


public XPCustomMemberInfo CreateMember(
    string propertyName,
    Type propertyType,
    params Attribute[] attributes
Public Function CreateMember(
    propertyName As String,
    propertyType As Type,
    ParamArray attributes As Attribute()
) As XPCustomMemberInfo


Name Type Description
propertyName String

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

propertyType Type

A Type descendant which represents the type of the new member. The created member type will be nullable, i.e if you pass bool, the type will be Nullable<bool>.

attributes Attribute[]

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


Type Description

An XPCustomMemberInfo descendant which provides the new member's metadata.


The CreateMember method allows custom members to be created dynamically.


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