Back to Devexpress

Session.GetKeyValue(Object) Method

xpo-devexpress-dot-xpo-dot-session-dot-getkeyvalue-x28-system-dot-object-x29.md

latest4.2 KB
Original Source

Session.GetKeyValue(Object) Method

Returns the key property’s value of the specified persistent object.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public object GetKeyValue(
    object theObject
)
vb
Public Function GetKeyValue(
    theObject As Object
) As Object

Parameters

NameTypeDescription
theObjectObject

An object which represents the persistent object whose key property’s value is returned.

|

Returns

TypeDescription
Object

An object which represents the key property’s value of the specified persistent object.

|

Remarks

If the specified persistent object is a null reference, a System.ArgumentNullException is thrown.

To set the value of the key property use the Session.SetKeyValue method.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetKeyValue(Object) 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-clone-a-persistent-object-e804/CS/SimpleObject/CloneHelper.cs#L77

csharp
if (synchronize && !cloneAlways) {
    clonedValue = targetSession.GetObjectByKey(targetSession.GetClassInfo(propertyValue), targetSession.GetKeyValue(propertyValue));
}

XPO_how-to-track-changes-made-to-persistent-objects-and-write-them-into-a-separate-table-e2419/CS/Q149895/Northwind.cs#L15

csharp
audit.Date = DateTime.Now;
audit.AuditedRecord = string.Format("{0}({1})", ClassInfo.FullName, Session.GetKeyValue(this));
audit.User = Environment.UserName;

XPO_how-to-track-changes-made-to-persistent-objects-and-write-them-into-a-separate-table-e2419/VB/Q149895/Northwind.vb#L19

vb
audit.Date = DateTime.Now
audit.AuditedRecord = String.Format("{0}({1})", ClassInfo.FullName, Session.GetKeyValue(Me))
audit.User = Environment.UserName

XPO_how-to-clone-a-persistent-object-e804/VB/SimpleObject/CloneHelper.vb#L80

vb
If synchronize AndAlso (Not cloneAlways) Then
    clonedValue = targetSession.GetObjectByKey(targetSession.GetClassInfo(propertyValue), targetSession.GetKeyValue(propertyValue))
End If

See Also

GetId(Object)

SetKeyValue(Object, Object)

GetObjectByKey

GetLoadedObjectByKey

Session Class

Session Members

DevExpress.Xpo Namespace