Class SessionObjectLayer
- Namespace
- DevExpress.Xpo
- Assembly
- DevExpress.Xpo.v24.1.dll
An object access layer that saves and loads persistent objects via a parent Session or UnitOfWork.
public class SessionObjectLayer : IObjectLayerForTests, IObjectLayer, IObjectLayerProvider, IObjectLayerEx, IDataLayerProvider, IXPDictionaryProvider, IObjectLayerOnSession, IObjectLayerAsync, ICommandChannel, ICommandChannelAsync
- Inheritance
-
SessionObjectLayer
- Implements
-
ICommandChannelICommandChannelAsync
- Inherited Members
Constructors
SessionObjectLayer(Session)
Initializes a new instance of the SessionObjectLayer class with a specified parent session.
public SessionObjectLayer(Session parentSession)
Parameters
parentSession
SessionA Session object specifying a parent session for the current object layer. The specified value initializes the object layer’s SessionObjectLayer.ParentSession field.
SessionObjectLayer(Session, bool)
Initializes a new instance of the SessionObjectLayer class with a specified parent session and the SessionObjectLayer.ThroughCommitMode field value.
public SessionObjectLayer(Session parentSession, bool throughCommitMode)
Parameters
parentSession
SessionA Session object specifying a parent session for the current object layer. The specified value initializes the object layer’s SessionObjectLayer.ParentSession field.
throughCommitMode
booltrue if the SessionObjectLayer.CommitChanges method call should automatically commit changes in the parentSession to properly update key fields and fields with enabled optimistic locking in the object layer’s session; otherwise, false. The specified value initializes the object layer’s SessionObjectLayer.ThroughCommitMode field.
SessionObjectLayer(Session, bool, IGenericSecurityRule, ISecurityRuleProvider, object)
Reserved for future use.
public SessionObjectLayer(Session parentSession, bool throughCommitMode, IGenericSecurityRule genericSecurityRule, ISecurityRuleProvider securityDictionary, object securityCustomContext)
Parameters
parentSession
SessionthroughCommitMode
boolgenericSecurityRule
IGenericSecurityRulesecurityDictionary
ISecurityRuleProvidersecurityCustomContext
object
Fields
ParentSession
Specifies a Session object which the current object layer uses to save and load objects.
public readonly Session ParentSession
Field Value
ThroughCommitMode
Indicates if the SessionObjectLayer.CommitChanges method call automatically commits changes in a parent session to properly update key fields and fields with enabled optimistic locking (decorated with the KeyAttribute or OptimisticLockingAttribute) in a nested session. To assign the ThroughCommitMode field, use the corresponding SessionObjectLayer overloaded constructor.
public readonly bool ThroughCommitMode
Field Value
Properties
AllowICommandChannelDoWithSecurityContext
protected virtual bool AllowICommandChannelDoWithSecurityContext { get; }
Property Value
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 SessionObjectLayer.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 SessionObjectLayer.LoadCollectionObjects method call; otherwise, false.
CanLoadCollectionObjectsAsynchronously
Indicates if an object layer can call the SessionObjectLayer.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 SessionObjectLayer.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 SessionObjectLayer object.
[Browsable(false)]
public IObjectLayer ObjectLayer { get; }
Property Value
- IObjectLayer
The current SessionObjectLayer 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
SessionA Session with pending object changes.
fullListForDelete
ICollectionA collection of persistent objects to be deleted.
completeListForSave
ICollectionA 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
SessionA Session with pending object changes.
fullListForDelete
ICollectionA collection of persistent objects to be deleted.
completeListForSave
ICollectionA collection of persistent objects to be saved.
callback
AsyncCommitCallbackAn 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
SessionA Session with pending object changes.
fullListForDelete
ICollectionA collection of persistent objects to be deleted.
completeListForSave
ICollectionA collection of persistent objects to be saved.
cancellationToken
CancellationTokenA 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 type)
Parameters
type
XPObjectTypeAn 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 type, CancellationToken cancellationToken)
Parameters
type
XPObjectTypeAn XPObjectType object specifying a valid persistent type.
cancellationToken
CancellationTokenA 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.
GetNestedParentMap(Session)
protected NestedParentMap GetNestedParentMap(Session session)
Parameters
session
Session
Returns
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
SessionA 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
SessionA Session that is used to load persistent objects.
queries
ObjectsByKeyQuery[]An array of ObjectsQuery objects that specifies queries executed to retrieve persistent objects.
cancellationToken
CancellationTokenA 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.
GetParentObjectsToDelete(Session)
Performs object layer specific operations that are required to return a collection of objects marked for deletion in parent sessions.
public ICollection GetParentObjectsToDelete(Session session)
Parameters
Returns
- ICollection
A collection of objects loaded to the session from the immediate parent session. Collection elements match objects marked for deletion in parent sessions.
GetParentObjectsToSave(Session)
Performs object layer specific operations that are required to return a collection of objects marked for saving in parent sessions.
public ICollection GetParentObjectsToSave(Session session)
Parameters
Returns
- ICollection
A collection of objects loaded to the session from the immediate parent session. Collection elements match objects marked for saving in parent sessions.
GetParentTouchedClassInfos(Session)
Performs object layer specific operations that are required to return the metadata of objects modified in parent sessions relative to a specified session.
public ICollection GetParentTouchedClassInfos(Session session)
Parameters
session
SessionA Session object specifying a session whose immediate parent session starts the search for modified objects up the nesting session hierarchy.
Returns
- ICollection
A collection of XPClassInfo objects identifying objects modified in parent sessions relative to the session.
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
IsParentObjectToDelete(Session, object)
Performs object layer specific operations that are required to determine if a specified object corresponds to an object marked for deletion in parent sessions.
public bool IsParentObjectToDelete(Session session, object theObject)
Parameters
session
SessionA Session object specifying a session which contains theObject.
theObject
objectThe session‘s object to test.
Returns
- bool
true if theObject corresponds to one of the objects marked for deletion in parent sessions; otherwise, false.
IsParentObjectToSave(Session, object)
Performs object layer specific operations that are required to determine if a specified object corresponds to an object marked for saving in parent sessions.
public bool IsParentObjectToSave(Session session, object theObject)
Parameters
session
SessionA Session object specifying a session which contains theObject.
theObject
objectThe session‘s object to test.
Returns
- bool
true if theObject corresponds to one of the objects marked for saving in parent sessions; otherwise, false.
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
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 owner)
Parameters
session
SessionA Session that is used to load collection objects.
refProperty
XPMemberInfoThe ownerObject‘s property that references a collection property.
owner
objectThe 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 owner, CancellationToken cancellationToken = default)
Parameters
session
SessionA Session that is used to asynchronously load collection objects.
refProperty
XPMemberInfoThe ownerObject‘s property that references a collection property.
owner
objectThe object that owns the collection property.
cancellationToken
CancellationTokenA 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
SessionA Session that is used to retrieve data for delayed properties.
objects
IListA list of persistent objects containing the delayed property specified by the property.
property
XPMemberInfoAn 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
SessionA Session that is used to retrieve data for delayed properties.
theObject
objectA persistent object containing delayed properties specified by the props.
props
MemberPathCollectionA 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
SessionA Session that is used to retrieve data for delayed properties.
objects
IListA list of persistent objects that contain the delayed property specified by the property.
property
XPMemberInfoAn XPMemberInfo object specifying a delayed property that accepts the data the LoadDelayedPropertiesAsync method loads.
cancellationToken
CancellationTokenA 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
SessionA Session that is used to retrieve data for delayed properties.
theObject
objectA persistent object that contains delayed properties specified by the props.
props
MemberPathCollectionA MemberPathCollection object that specifies member paths for delayed properties where the LoadDelayedPropertiesAsync method loads data from a session.
cancellationToken
CancellationTokenA CancellationToken object that delivers cancellation notice to the running operation.
Returns
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
SessionA 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
SessionA 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
AsyncLoadObjectsCallbackAn 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
SessionA Session that is used to load persistent objects.
queries
ObjectsQuery[]An array of ObjectsQuery objects that specifies queries executed to retrieve persistent objects.
cancellationToken
CancellationTokenA 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.
OnLoadedObjects(ICollection[], ICollection[], NestedParentMap, SecurityContext)
protected virtual void OnLoadedObjects(ICollection[] parentObjects, ICollection[] nestedObjects, NestedParentMap nestedParentMap, SecurityContext securityContext)
Parameters
parentObjects
ICollection[]nestedObjects
ICollection[]nestedParentMap
NestedParentMapsecurityContext
SecurityContext
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
SessionA Session that is used to retrieve persistent objects.
query
ObjectsQueryAn ObjectsQuery object specifying a query that is executed to retrieve persistent objects.
properties
CriteriaOperatorCollectionA DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies object properties to be retrieved.
groupProperties
CriteriaOperatorCollectionA DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies the grouping properties.
groupCriteria
CriteriaOperatorA 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
SessionA Session that is used to retrieve persistent objects.
query
ObjectsQueryAn ObjectsQuery object specifying a query that is executed to retrieve persistent objects.
properties
CriteriaOperatorCollectionA DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies object properties to be retrieved.
groupProperties
CriteriaOperatorCollectionA DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies the grouping properties.
groupCriteria
CriteriaOperatorA DevExpress.Data.Filtering.CriteriaOperator descendant which specifies the grouping criteria for the retrieved objects.
callback
AsyncSelectDataCallbackAn 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
SessionA Session that is used to retrieved persistent objects.
query
ObjectsQueryAn array of ObjectsQuery objects that specifies queries executed to select data.
properties
CriteriaOperatorCollectionA DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies object properties to be retrieved.
groupProperties
CriteriaOperatorCollectionA DevExpress.Data.Filtering.CriteriaOperatorCollection object which specifies the grouping properties.
groupCriteria
CriteriaOperatorA DevExpress.Data.Filtering.CriteriaOperator descendant which specifies the grouping criteria for the retrieved objects.
cancellationToken
CancellationTokenA 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
booltrue 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
CancellationTokenA CancellationToken object that delivers a cancellation notice to the running operation.
doNotCreateIfFirstTableNotExist
booltrue 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
CustomSecurityCriteriaPatcher
public event EventHandler<CustomSecurityCriteriaPatcherEventArgs> CustomSecurityCriteriaPatcher
Event Type
ObjectsLoaded
public event EventHandler<ObjectsLoadedEventArgs> ObjectsLoaded
Event Type
SchemaInit
Occurs when a data store’s schema is initialized or updated for the current object layer.
public event SchemaInitEventHandler SchemaInit