Base Persistent Classes(基本持久化类)
This topic describes the base persistent classes that can be used in XAF applications when creating a data model with XPO.
本主题介绍在使用XPO创建数据模型时可在XAF应用程序中使用的基本持久类。
The following table lists the base persistent classes you can inherit from when you define persistent business classes:
下表列出了定义持久业务类时可以继承的基本持久类:
The BaseObject class is used when creating business classes from the XPO Business Object template. It is a feature-rich persistent class that supports the optimistic concurrency control (optimistic locking mechanism).
BaseObject类用于从XPO Business Object模板创建业务类。它是一个功能丰富的持久类,支持乐观并发控制(乐观锁定机制)。
We recommend using the XPObject class if your business class should use the integer type primary key. This class also supports optimistic concurrency control.
如果您的业务类应该使用整数类型主键,我们建议使用XPObject类。此类还支持乐观并发控制。
You need to define the primary key property in the business class declaration if you are using classes which do not have the auto-generated primary key property. The following code snippet illustrates this:
如果您使用的类没有自动生成的主键属性,则需要在业务类声明中定义主键属性。以下代码片段说明了这一点:
C#
using System.ComponentModel;
using DevExpress.Persistent.Base;
using DevExpress.Xpo;
//...
[DefaultClassOptions]
public class MyClass : XPLiteObject {
public MyClass(Session session) : base(session) { }
[Key(AutoGenerate = true), Browsable(false)]
public int Oid { get; set; }
string fMyProperty;
public string MyProperty {
get { return fMyProperty; }
set { SetPropertyValue(nameof(MyProperty), ref fMyProperty, value); }
}
}
If you need to consider whether to use a base class that supports the deferred deletion feature, refer to the XPO documentation: Deleting Persistent Objects.
如果您需要考虑是否使用支持延迟删除功能的基类,请参阅XPO留档:删除持久对象。
You can implement a custom base persistent class. To learn more, refer to the How to: Implement a Custom Base Persistent Class help topic.
您可以实现自定义基础持久类。要了解更多信息,请参阅如何:实现自定义基础持久类帮助主题。