xpo-devexpress-dot-xpo-dot-metadata-dot-xpdictionary-dot-createclass-x28-devexpress-dot-xpo-dot-metadata-dot-xpclassinfo-system-dot-string-system-dot-attribute-x29.md
Creates a class with the specified name and attributes.
Namespace : DevExpress.Xpo.Metadata
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
public XPClassInfo CreateClass(
XPClassInfo baseClassInfo,
string className,
params Attribute[] attributes
)
Public Function CreateClass(
baseClassInfo As XPClassInfo,
className As String,
ParamArray attributes As Attribute()
) As XPClassInfo
| Name | Type | Description |
|---|---|---|
| baseClassInfo | XPClassInfo |
An XPClassInfo object which provides the metadata information of the base class.
| | className | String |
A String value that specifies the class name.
| | attributes | Attribute[] |
An array of attributes.
|
| Type | Description |
|---|---|
| XPClassInfo |
The XPClassInfo for the created class.
|
The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateClass(XPClassInfo, String, 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.
XPO_how-to-persist-metadata-e269/CS/MetadataObjects.cs#L58
baseClassInfo = dictionary.GetClassInfo(GetDefaultBaseClass());
result = dictionary.CreateClass(baseClassInfo, Name);
CreateAttributes(result);
XPO_how-to-define-a-persistent-class-at-runtime-e1139/CS/CreateClassAtRuntime/Program.cs#L17
XPClassInfo myBaseClass = dictionary.GetClassInfo(typeof(MyBaseObject));
XPClassInfo myClassA = dictionary.CreateClass(myBaseClass, "MyObjectA");
myClassA.CreateMember("ID", typeof(int), new KeyAttribute(true));
DBTable table = tables[0];
XPClassInfo info = XpoDefault.Dictionary.CreateClass(XpoDefault.Dictionary.QueryClassInfo(baseType), table.Name);
string key = table.PrimaryKey.Columns[0];
throw new NotSupportedException("Compound primary keys are not supported");
XPClassInfo classInfo = dict.CreateClass(dict.GetClassInfo(typeof(BasePersistentClass)), table.Name.Replace('.', '_'));
classInfo.AddAttribute(new PersistentAttribute(table.Name));
XPO_how-to-persist-metadata-e269/VB/MetadataObjects.vb#L83
result = dictionary.CreateClass(baseClassInfo, Name)
CreateAttributes(result)
Dim table As DBTable = tables(0)
Dim info As XPClassInfo = XpoDefault.Dictionary.CreateClass(XpoDefault.Dictionary.QueryClassInfo(baseType), table.Name)
Dim key As String = table.PrimaryKey.Columns(0)
See Also
How to create persistent metadata on the fly and load data from an arbitrary table