Skip to main content
A newer version of this page is available. .

BaseObject.Oid Property

Specifies the persistent object’s identifier.

Namespace: DevExpress.Persistent.BaseImpl

Assembly: DevExpress.Persistent.BaseImpl.v18.1.dll

Declaration

[VisibleInLookupListView(false)]
[PersistentAlias("oid")]
[VisibleInListView(false)]
[VisibleInDetailView(false)]
public Guid Oid { get; }

Property Value

Type Description
Guid

A globally unique identifier which represents the persistent object’s identifier.

Remarks

To distinguish between different business objects and correctly identify them, the BaseObject class exposes the Oid property. This is an auto-generated property, meaning you do not need to assign identifier values for each persistent object. The Oid property can also be referred to as a primary key property, since it is represented by a primary key in the database. Note that after a new object is created, and until it is persisted in the database, the Oid property returns Guid.Empty (all zeroes). So, until an object is persisted in a database, it does not have a unique identifier.

The XPObjectSpace class exposes a number of methods that take the value returned by a business object’s Oid property, as a parameter. These methods allow you to find a particular object by its key property value, as well as perform additional actions based on it. The following table lists these methods.

Note

The BaseObject‘s Oid property, as well as other base classes key properties, is not designed to be manually set. In fact, this is not supported and should never be done. Under normal circumstances, the Oid property does not even expose a setter. However, in a medium trust environment, the XPO cannot change a private field’s value. So, in this instance, the only way for auto-generated primary keys to work is to expose a public setter. However, it is exposed purely for internal purposes.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Oid property.

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.

See Also