Table of Contents

Class SimpleObjectLayer

Namespace
DevExpress.Xpo
Assembly
DevExpress.Xpo.v24.1.dll

An object access layer that saves and loads persistent objects via a data access layer associated with a data store provider (an DevExpress.Xpo.DB.IDataStore implementation).

public class SimpleObjectLayer : IObjectLayerForTests, IObjectLayer, IObjectLayerProvider, IObjectLayerEx, IDataLayerProvider, IXPDictionaryProvider, IObjectLayerAsync, ICommandChannel, ICommandChannelAsync
Inheritance
SimpleObjectLayer
Implements
ICommandChannel
ICommandChannelAsync
Inherited Members

Constructors

SimpleObjectLayer(IDataLayer)

Initializes a new instance of the SimpleObjectLayer class with a specified data access layer.

public SimpleObjectLayer(IDataLayer dataLayer)

Parameters

dataLayer IDataLayer

An object which implements the IDataLayer interface. A data access layer.

Properties

AutoCreateOption

Returns an DevExpress.Xpo.DB.AutoCreateOption value associated with the current object layer.

[Browsable(false)]
public AutoCreateOption AutoCreateOption { get; }

Property Value

AutoCreateOption

An DevExpress.Xpo.DB.AutoCreateOption enumeration value which specifies the action which is performed when connecting to a data store.

CanLoadCollectionObjects

Indicates if an object layer can call the SimpleObjectLayer.LoadCollectionObjects method to load collection properties.

[Browsable(false)]
public bool CanLoadCollectionObjects { get; }

Property Value

bool

true if collections can be loaded via an object layer’s SimpleObjectLayer.LoadCollectionObjects method call; otherwise, false.

CanLoadCollectionObjectsAsynchronously

Indicates if an object layer can call the SimpleObjectLayer.LoadCollectionObjectsAsync method to asynchronously load collection properties.

[Browsable(false)]
public bool CanLoadCollectionObjectsAsynchronously { get; }

Property Value

bool

true if collections can be asynchronously loaded via an object layer’s SimpleObjectLayer.LoadCollectionObjectsAsync method call; otherwise, false.

Connection

Provides access to the current object layer’s IDbConnection object that is used to access a database.

[Browsable(false)]
public IDbConnection Connection { get; }

Property Value

IDbConnection

An object which implements the IDbConnection interface.

DataLayer

Provides access to the current object layer’s data access layer that is used to access a data store.

[Browsable(false)]
public IDataLayer DataLayer { get; }

Property Value

IDataLayer

An object which implements the IDataLayer interface.

Dictionary

Gets an object providing metadata on persistent objects stored in a data store.

[Browsable(false)]
public XPDictionary Dictionary { get; }

Property Value

XPDictionary

An XPDictionary object, which provides metadata on persistent objects stored in a data store.

ObjectLayer

Returns the current SimpleObjectLayer object.

[Browsable(false)]
public IObjectLayer ObjectLayer { get; }

Property Value

IObjectLayer

The current SimpleObjectLayer object cast to the IObjectLayer.

Methods

ClearDatabase()

This member supports the internal infrastructure and is not intended to be used directly from your code.

public void ClearDatabase()

CommitChanges(Session, ICollection, ICollection)

Performs object layer specific operations that are required to commit object changes made in a specified session.

public void CommitChanges(Session session, ICollection fullListForDelete, ICollection completeListForSave)

Parameters

session Session

A Session with pending object changes.

fullListForDelete ICollection

A collection of persistent objects to be deleted.

completeListForSave ICollection

A collection of persistent objects to be saved.

CommitChangesAsync(Session, ICollection, ICollection, AsyncCommitCallback)

Performs object layer specific operations that are required to asynchronously commit object changes made in a specified session and notifies upon completion.

public object CommitChangesAsync(Session session, ICollection fullListForDelete, ICollection completeListForSave, AsyncCommitCallback callback)

Parameters

session Session

A Session with pending object changes.

fullListForDelete ICollection

A collection of persistent objects to be deleted.

completeListForSave ICollection

A collection of persistent objects to be saved.

callback AsyncCommitCallback

An AsyncCommitCallback delegate to be called after the changes have been committed. Use the callback to store the exception information passed as a parameter, and use this information later, to raise the exception again, within the original thread. Do not raise exceptions or modify persistent objects within a callback.

Returns

object

An object identifying the current asynchronous operation, intended for internal use.

CommitChangesAsync(Session, ICollection, ICollection, CancellationToken)

Asynchronously commits object changes made in a specified session and notifies upon completion.

public Task CommitChangesAsync(Session session, ICollection fullListForDelete, ICollection completeListForSave, CancellationToken cancellationToken = default)

Parameters

session Session

A Session with pending object changes.

fullListForDelete ICollection

A collection of persistent objects to be deleted.

completeListForSave ICollection

A collection of persistent objects to be saved.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task

A Task that commits specified object changes.

CreateObjectType(XPObjectType)

Performs object layer specific operations that are required to create an XPObjectType record.

public void CreateObjectType(XPObjectType objectType)

Parameters

objectType XPObjectType

An XPObjectType object specifying a valid persistent type.

CreateObjectTypeAsync(XPObjectType, CancellationToken)

Asynchronously performs object layer specific operations that are required to create an XPObjectType record.

public Task CreateObjectTypeAsync(XPObjectType objectType, CancellationToken cancellationToken)

Parameters

objectType XPObjectType

An XPObjectType object specifying a valid persistent type.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task

A Task that performs object layer specific operations that are required to create an XPObjectType record.

FromDataLayer(IDataLayer)

Creates a new SimpleObjectLayer and initializes it with a specified data access layer.

public static SimpleObjectLayer FromDataLayer(IDataLayer dataLayer)

Parameters

dataLayer IDataLayer

An object implementing the IDataLayer interface.

Returns

SimpleObjectLayer

A SimpleObjectLayer object which is initialized with the dataLayer. null (Nothing in Visual Basic) is returned if the dataLayer is not specified.

GetObjectLayerWideObjectTypes()

Returns a Dictionary<XPClassInfo,XPObjectType> specifying the correspondence of XPClassInfo objects to XPObjectType records.

public Dictionary<XPClassInfo, XPObjectType> GetObjectLayerWideObjectTypes()

Returns

Dictionary<XPClassInfo, XPObjectType>

A Dictionary<XPClassInfo,XPObjectType>, providing a collection of complementary XPClassInfo-XPObjectType pairs.

GetObjectsByKey(Session, ObjectsByKeyQuery[])

Performs object layer specific operations that are required to return persistent objects from a specified session using queries based on specified object types and key values.

public ICollection[] GetObjectsByKey(Session session, ObjectsByKeyQuery[] queries)

Parameters

session Session

A Session that is used to retrieve persistent objects.

queries ObjectsByKeyQuery[]

An array of ObjectsByKeyQuery objects, containing data for queries that retrieve persistent objects by specified object types and key values.

Returns

ICollection[]

An array of persistent object collections retrieved for query data passed as the queries parameter.

GetObjectsByKeyAsync(Session, ObjectsByKeyQuery[], CancellationToken)

Retrieves object data from a session asynchronously, according to specified query parameters.

public Task<ICollection[]> GetObjectsByKeyAsync(Session session, ObjectsByKeyQuery[] queries, CancellationToken cancellationToken = default)

Parameters

session Session

A Session that is used to load persistent objects.

queries ObjectsByKeyQuery[]

An array of ObjectsQuery objects that specifies queries executed to retrieve persistent objects.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task<ICollection[]>

A Task that returns an array of object collections. These object collections match specified query parameters.

GetStaticCache(XPClassInfo)

This member supports the internal infrastructure and is not intended to be used directly from your code.

public IObjectMap GetStaticCache(XPClassInfo info)

Parameters

info XPClassInfo

Returns

IObjectMap

IsStaticType(XPClassInfo)

This member supports the internal infrastructure and is not intended to be used directly from your code.

public bool IsStaticType(XPClassInfo type)

Parameters

type XPClassInfo

Returns

bool

LoadCollectionObjects(Session, XPMemberInfo, object)

Performs object layer specific operations that are required to load a collection property using specified settings.

public object[] LoadCollectionObjects(Session session, XPMemberInfo refProperty, object ownerObject)

Parameters

session Session

A Session that is used to load collection objects.

refProperty XPMemberInfo

The ownerObject‘s property that references a collection property.

ownerObject object

The object that owns the collection property.

Returns

object[]

An array of collection objects.

LoadCollectionObjectsAsync(Session, XPMemberInfo, object, CancellationToken)

Performs object layer specific operations that are required to asynchronously load a collection property using specified settings.

public Task<object[]> LoadCollectionObjectsAsync(Session session, XPMemberInfo refProperty, object ownerObject, CancellationToken cancellationToken = default)

Parameters

session Session

A Session that is used to asynchronously load collection objects.

refProperty XPMemberInfo

The ownerObject‘s property that references a collection property.

ownerObject object

The object that owns the collection property.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task<object[]>

A Task<TResult> that returns an array of collection objects.

LoadDelayedProperties(Session, IList, XPMemberInfo)

Performs object layer specific operations that are required to load data to a specific property marked for delayed loading in specified objects.

public ObjectDictionary<object> LoadDelayedProperties(Session session, IList objects, XPMemberInfo property)

Parameters

session Session

A Session that is used to retrieve data for delayed properties.

objects IList

A list of persistent objects containing the delayed property specified by the property.

property XPMemberInfo

An XPMemberInfo object specifying a delayed property whose values are loaded.

Returns

ObjectDictionary<object>

An ObjectDictionary of loaded property values that correspond to the objects list elements.

LoadDelayedProperties(Session, object, MemberPathCollection)

Performs object layer specific operations that are required to load data to specific properties marked for delayed loading in a specified object.

public object[] LoadDelayedProperties(Session session, object theObject, MemberPathCollection props)

Parameters

session Session

A Session that is used to retrieve data for delayed properties.

theObject object

A persistent object containing delayed properties specified by the props.

props MemberPathCollection

A MemberPathCollection object containing member paths of delayed properties whose values are loaded.

Returns

object[]

An array of loaded property values that correspond to the props collection elements.

LoadDelayedPropertiesAsync(Session, IList, XPMemberInfo, CancellationToken)

Asynchronously loads data from a session to an object’s specific properties marked for delayed loading.

public Task<ObjectDictionary<object>> LoadDelayedPropertiesAsync(Session session, IList objects, XPMemberInfo property, CancellationToken cancellationToken = default)

Parameters

session Session

A Session that is used to retrieve data for delayed properties.

objects IList

A list of persistent objects that contain the delayed property specified by the property.

property XPMemberInfo

An XPMemberInfo object specifying a delayed property that accepts the data the LoadDelayedPropertiesAsync method loads.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task<ObjectDictionary<object>>

A Task that returns an array of loaded property values.

LoadDelayedPropertiesAsync(Session, object, MemberPathCollection, CancellationToken)

Asynchronously loads data from a session to an object’s specific properties marked for delayed loading.

public Task<object[]> LoadDelayedPropertiesAsync(Session session, object theObject, MemberPathCollection props, CancellationToken cancellationToken = default)

Parameters

session Session

A Session that is used to retrieve data for delayed properties.

theObject object

A persistent object that contains delayed properties specified by the props.

props MemberPathCollection

A MemberPathCollection object that specifies member paths for delayed properties where the LoadDelayedPropertiesAsync method loads data from a session.

cancellationToken CancellationToken

A CancellationToken object that delivers cancellation notice to the running operation.

Returns

Task<object[]>

A Task that returns an array of loaded property values.

LoadObjects(Session, ObjectsQuery[])

Performs object layer specific operations that are required to load persistent objects using specified settings.

public ICollection[] LoadObjects(Session session, ObjectsQuery[] queries)

Parameters

session Session

A Session that is used to load persistent objects.

queries ObjectsQuery[]

An array of ObjectsQuery objects specifying queries that are executed to retrieve persistent objects.

Returns

ICollection[]

An array of object collections that correspond to the queries.

LoadObjectsAsync(Session, ObjectsQuery[], AsyncLoadObjectsCallback)

Performs object layer specific operations that are required to asynchronously load persistent objects using specified settings and notifies upon completion.

public object LoadObjectsAsync(Session session, ObjectsQuery[] queries, AsyncLoadObjectsCallback callback)

Parameters

session Session

A Session that is used to load persistent objects.

queries ObjectsQuery[]

An array of ObjectsQuery objects specifying queries that are executed to retrieve persistent objects.

callback AsyncLoadObjectsCallback

An AsyncLoadObjectsCallback delegate to be called after the objects have been loaded. Use the callback to store the exception information passed as a parameter, and use this information later, to raise the exception again, within the original thread. Do not raise exceptions or modify persistent objects within a callback.

Returns

object

An object identifying the current asynchronous operation, intended for internal use.

LoadObjectsAsync(Session, ObjectsQuery[], CancellationToken)

Loads persistent objects asynchronously, according to specified query parameters.

public Task<ICollection[]> LoadObjectsAsync(Session session, ObjectsQuery[] queries, CancellationToken cancellationToken = default)

Parameters

session Session

A Session that is used to load persistent objects.

queries ObjectsQuery[]

An array of ObjectsQuery objects that specifies queries executed to retrieve persistent objects.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task<ICollection[]>

A Task that returns an array of object collections. These object collections match specified query parameters.

Purge()

Performs object layer specific operations that are required to remove all objects marked for deletion.

public PurgeResult Purge()

Returns

PurgeResult

A PurgeResult object containing removal statistics (the number of objects processed, purged, etc.)

RegisterStaticTypes(params XPClassInfo[])

This member supports the internal infrastructure and is not intended to be used directly from your code.

public void RegisterStaticTypes(params XPClassInfo[] types)

Parameters

types XPClassInfo[]

SelectData(Session, ObjectsQuery, CriteriaOperatorCollection, CriteriaOperatorCollection, CriteriaOperator)

Performs object layer specific operations that are required to retrieve object data from a session using specified query parameters.

public List<object[]> SelectData(Session session, ObjectsQuery query, CriteriaOperatorCollection properties, CriteriaOperatorCollection groupProperties, CriteriaOperator groupCriteria)

Parameters

session Session

A Session that is used to retrieve persistent objects.

query ObjectsQuery

An ObjectsQuery object specifying a query that is executed to retrieve persistent objects.

properties CriteriaOperatorCollection

A DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies object properties to be retrieved.

groupProperties CriteriaOperatorCollection

A DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies the grouping properties.

groupCriteria CriteriaOperator

A DevExpress.Data.Filtering.CriteriaOperator descendant which specifies the grouping criteria for the retrieved objects.

Returns

List<object[]>

A list whose elements are property values that correspond to the properties of objects retrieved from the session.

SelectDataAsync(Session, ObjectsQuery, CriteriaOperatorCollection, CriteriaOperatorCollection, CriteriaOperator, AsyncSelectDataCallback)

Performs object layer specific operations that are required to asynchronously retrieve object data from a session using specified query parameters and notifies upon completion.

public object SelectDataAsync(Session session, ObjectsQuery query, CriteriaOperatorCollection properties, CriteriaOperatorCollection groupProperties, CriteriaOperator groupCriteria, AsyncSelectDataCallback callback)

Parameters

session Session

A Session that is used to retrieve persistent objects.

query ObjectsQuery

An ObjectsQuery object specifying a query that is executed to retrieve persistent objects.

properties CriteriaOperatorCollection

A DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies object properties to be retrieved.

groupProperties CriteriaOperatorCollection

A DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies the grouping properties.

groupCriteria CriteriaOperator

A DevExpress.Data.Filtering.CriteriaOperator descendant which specifies the grouping criteria for the retrieved objects.

callback AsyncSelectDataCallback

An AsyncLoadObjectsCallback delegate to be called after the object data have been retrieved. Use the callback to store the exception information passed as a parameter, and use this information later, to raise the exception again, within the original thread. Do not raise exceptions or modify persistent objects within a callback.

Returns

object

An object identifying the current asynchronous operation, intended for internal use.

SelectDataAsync(Session, ObjectsQuery, CriteriaOperatorCollection, CriteriaOperatorCollection, CriteriaOperator, CancellationToken)

Retrieves object data from a session asynchronously, according to specified query parameters.

public Task<List<object[]>> SelectDataAsync(Session session, ObjectsQuery query, CriteriaOperatorCollection properties, CriteriaOperatorCollection groupProperties, CriteriaOperator groupCriteria, CancellationToken cancellationToken = default)

Parameters

session Session

A Session that is used to retrieved persistent objects.

query ObjectsQuery

An array of ObjectsQuery objects that specifies queries executed to select data.

properties CriteriaOperatorCollection

A DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies object properties to be retrieved.

groupProperties CriteriaOperatorCollection

A DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies the grouping properties.

groupCriteria CriteriaOperator

A DevExpress.Data.Filtering.CriteriaOperator descendant which specifies the grouping criteria for the retrieved objects.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task<List<object[]>>

A Task that returns a list of object arrays. These object arrays match specified query parameters.

SetObjectLayerWideObjectTypes(Dictionary<XPClassInfo, XPObjectType>)

Designates a Dictionary<XPClassInfo,XPObjectType> specifying the correspondence of XPClassInfo objects to XPObjectType records.

public void SetObjectLayerWideObjectTypes(Dictionary<XPClassInfo, XPObjectType> loadedTypes)

Parameters

loadedTypes Dictionary<XPClassInfo, XPObjectType>

A Dictionary<XPClassInfo,XPObjectType>, providing a collection of complementary XPClassInfo-XPObjectType pairs.

UpdateSchema(bool, params XPClassInfo[])

Performs object layer specific operations that are required to update a data store’s schema according to the class descriptions of the specified types.

public UpdateSchemaResult UpdateSchema(bool doNotCreateIfFirstTableNotExist, params XPClassInfo[] types)

Parameters

doNotCreateIfFirstTableNotExist bool

true if the schema should not be created when the table that corresponds to the first item in the types array doesn’t exist in the data store; otherwise, false.

types XPClassInfo[]

An array of XPClassInfo objects specifying the types of objects for which schema should be created in the data store.

Returns

UpdateSchemaResult

An DevExpress.Xpo.DB.UpdateSchemaResult enumeration value which specifies the result of the update operation.

UpdateSchemaAsync(CancellationToken, bool, params XPClassInfo[])

Asynchronously performs object layer specific operations that are required to update a data store’s schema according to the class descriptions of the specified types.

public Task<UpdateSchemaResult> UpdateSchemaAsync(CancellationToken cancellationToken, bool doNotCreateIfFirstTableNotExist, params XPClassInfo[] types)

Parameters

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

doNotCreateIfFirstTableNotExist bool

true if the schema should not be created when the table that corresponds to the first item in the types array doesn’t exist in the data store; otherwise, false.

types XPClassInfo[]

An array of XPClassInfo objects specifying the types of objects for which schema should be created in the data store.

Returns

Task<UpdateSchemaResult>

A Task<TResult> that returns an DevExpress.Xpo.DB.UpdateSchemaResult enumeration value which specifies the result of the update operation.

Events

SchemaInit

Occurs when a data store’s schema is initialized or updated for the current object layer.

public event SchemaInitEventHandler SchemaInit

Event Type

SchemaInitEventHandler