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

Session.GetObjectByKey<ClassType>(Object, Boolean) 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.v18.2.dll

Declaration

public ClassType GetObjectByKey<ClassType>(
    object id,
    bool alwaysGetFromDataStore
)

Parameters

Name Type Description
id Object

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

alwaysGetFromDataStore Boolean

true to reload the persistent object from storage if it is found in memory; otherwise, false.

Type Parameters

Name
ClassType

Returns

Type Description
ClassType

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

Remarks

Firstly, the GetObjectByKey<ClassType> method searches the memory for the object with the specified value of the key property. If such an object is found, it is not reloaded. To get the up-to-date object from the data store, the alwaysGetFromDb parameter must be set to true.

Note

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetObjectByKey<ClassType>(Object, Boolean) 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.

See Also