The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Session.GetObjectByKey<ClassType>(Object) Method

Returns a persistent object of the type designated by the specified generic type parameter, with the specified value for its key property.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public ClassType GetObjectByKey<ClassType>(
    object id
)
Public Function GetObjectByKey(Of ClassType)(
    id As Object
) As ClassType
public ClassType GetObjectByKey<ClassType>(
    object id
)
Public Function GetObjectByKey(Of ClassType)(
    id As Object
) As ClassType

Parameters

Name Type Description
id Object

An object that represents the persistent object's key property value.

Parameters

Name Type Description
id Object

An object that represents the persistent object's key property value.

Returns

Type Description
ClassType

An object which represents a persistent object with the specified value for its key property.

Returns

Type Description
ClassType

An object which represents a persistent object with the specified value for its key property.

Type Parameters

Name Description
ClassType

Type Parameters

Name Description
ClassType

Remarks

Below is an example of using the GetObjectByKey<ClassType> method. Here, session is the Session instance.

using DevExpress.Xpo;
// ...
Person personToDelete = session.GetObjectByKey<Person>(152);
session.Delete(personToDelete);

The GetObjectByKey<ClassType> method searches the memory for the object that has the specified value for its key property. If such an object is found, it is not reloaded. To get the up-to-date object from the storage, use the overloaded Session.GetObjectByKey method with the alwaysGetFromDb parameter set to true.

Note

The GetObjectByKey<ClassType> method does not find objects until they are saved to a data store.

See Also