Click or drag to resize
UnitOfWork Class
UnitOfWork class. Can collect actions to perform on the entities/entity collections specified. Will not perform these actions until Commit(transaction) is called. A UnitOfWork is meant to make development easier. It will not prohibit the developer to persist the actions also using other methods. Selfservicing Specific.
Async part of UnitOfWork class
Inheritance Hierarchy
SystemObject
  SD.LLBLGen.Pro.ORMSupportClassesUnitOfWork

Namespace:  SD.LLBLGen.Pro.ORMSupportClasses
Assembly:  SD.LLBLGen.Pro.ORMSupportClasses (in SD.LLBLGen.Pro.ORMSupportClasses.dll) Version: 5.2.0.0 (5.2.17.0403)
Syntax
[SerializableAttribute]
public class UnitOfWork : IUnitOfWorkCore, ISerializable

The UnitOfWork type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCommitOrder
Gets / sets the Commit Order of the various blocks the unit of work groups the elements in.
Public propertyOptimizedSerialization
Gets / sets the OptimizedSerialization flag. Default: true. When set to false, the serialization logic will simply serialize all entities inside the unit of work. When set to true, the unit of work will first calculate the save queues, which weeds out entities which aren't changed and won't be saved anyway, so these don't have to be sent over the wire.
Top
Methods
  NameDescription
Public methodAddCallBack(Delegate, UnitOfWorkCallBackScheduleSlot, Object)
Adds the call back passed in, to the slot specified with the parameters specified.
Public methodAddCallBack(Delegate, UnitOfWorkCallBackScheduleSlot, Boolean, Object)
Adds the call back passed in, to the slot specified with the parameters specified.
Public methodAddCollectionForDelete
Adds the collection with entities for deletion.
Public methodAddCollectionForSave(IEntityCollection)
Adds the collection with entities for saving.
Public methodAddCollectionForSave(IEntityCollection, Boolean)
Adds the collection with entities for saving.
Public methodAddDeleteMultiCall(IEntityCollection, IPredicate)
Adds a call to collection.DeleteMulti(filter) to delete entities directly from the database using the passed in criteria. The call will be executed inside the transaction used in Commit and will be executed after the last entity has been deleted but before the PostEntityDelete callbacks.
Public methodAddDeleteMultiCall(IEntityCollection, IPredicate, IRelationCollection)
Adds a call to collection.DeleteMulti(filter, relations) to delete entities directly from the database using the passed in criteria. The call will be executed inside the transaction used in Commit and will be executed after the last entity has been deleted but before the PostEntityDelete callbacks.
Public methodAddForDelete(IEntity)
Adds the passed in entity for deletion.
Public methodAddForDelete(IEntity, IPredicate)
Adds the passed in entity for deletion.
Public methodAddForSave(IEntity)
Adds the passed in entity for saving. No recursion will be applied during the save of this entity when the unit of work is committed.
Public methodAddForSave(IEntity, IPredicate)
Adds the passed in entity for saving. No recursion will be applied during the save of this entity when the unit of work is committed.
Public methodAddForSave(IEntity, Boolean)
Adds the passed in entity for saving.
Public methodAddForSave(IEntity, IPredicate, Boolean)
Adds the passed in entity for saving.
Public methodAddUpdateMultiCall(IEntityCollection, IEntity, IPredicate)
Adds a call to collection.UpdateMulti(Entity, filter) to update entities directly in the database using the passed in criteria. The call will be executed inside the transaction used in Commit and will be executed after the last entity has been updated but before the PreEntityUpdate callbacks.
Public methodAddUpdateMultiCall(IEntityCollection, IEntity, IPredicate, IRelationCollection)
Adds a call to collection.UpdateMulti(Entity, filter, relations) to update entities directly in the database using the passed in criteria. The call will be executed inside the transaction used in Commit and will be executed after the last entity has been updated but before the PreEntityUpdate callbacks.
Public methodCommit(ITransaction)
Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes.
Public methodCommit(ITransaction, Boolean)
Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes.
Public methodCommitAsync(ITransaction)
Async variant of Commit(ITransaction). Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes.
Public methodCommitAsync(ITransaction, Boolean)
Async variant of Commit(ITransaction, Boolean). Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes.
Public methodCommitAsync(ITransaction, CancellationToken)
Async variant of Commit(ITransaction). Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes.
Public methodCommitAsync(ITransaction, Boolean, CancellationToken)
Async variant of Commit(ITransaction, Boolean). Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes.
Public methodConstructSaveProcessQueues
Constructs the save process queues for insert and update actions. These queues are constructed from the entities added to this UoW for save either individually or in a collection. Call this method to determine what the sequence will be for the insert and update actions executed during Commit(). Commit() uses this method as well as well as the serialization/deserialization logic, to avoid sending large object graphs with few changes.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetCollectionElementsToDelete
Gets the UnitOfWorkCollectionElements with the collections which are added with AddCollectionForDelete, in a new List. To remove a collection, call RemoveCollectionFromUoW(IEntityCollection)
Public methodGetCollectionElementsToSave
Gets the UnitOfWorkCollectionElement objects with the collections which are added with AddCollectionForSave, in a new List To remove a collection, call RemoveCollectionFromUoW(IEntityCollection)
Public methodGetEntityElementsToDelete
Gets the UnitOfWorkElements with the entities which are added with AddForDelete, in a new list. To remove an entity, call RemoveFromUoW(IEntity)
Public methodGetEntityElementsToInsert
Gets the UnitOfWorkElements with the entities which are added with AddForSave and which are new. To remove an entity, call RemoveFromUoW(IEntity)
Public methodGetEntityElementsToUpdate
Gets the UnitOfWorkElements with the entities which are added with AddForSave and which are not new . To remove an entity, call RemoveFromUoW(IEntity)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetInsertQueue
Gets the insert queue, which is a list of ActionQueueElements(of IEntity) which have been placed in the insert queue. This queue is empty unless ConstructSaveProcessQueues has been called, or Commit has been called, which calls ConstructSaveProcessQueues under the hood. If this method is called after Commit, and Commit succeeded, the entities in the queue returned are saved succesfully. Calling Reset will not clear the queues, only ConstructSaveProcessQueues or Commit will.
Public methodGetObjectData
Gets the object data.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetUpdateQueue
Gets the update queue, which is a list of ActionQueueElements(of IEntity) which have been placed in the update queue. This queue is empty unless ConstructSaveProcessQueues has been called, or Commit has been called, which calls ConstructSaveProcessQueues under the hood. If this method is called after Commit, and Commit succeeded, the entities in the queue returned are saved succesfully. Calling Reset will not clear the queues, only ConstructSaveProcessQueues or Commit will.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemoveCollectionFromUoW
Removes the specified entity collection from this UnitOfWork.
Public methodRemoveFromUoW
Removes the specified entity from this UnitOfWork. If the entity is in an added collection, the entity will later on still be added.
Public methodReset
Resets the inner contents of this unit of work.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodIUnitOfWorkCoreAddCollectionForDelete
Adds the collection with entities for deletion.
Explicit interface implementationPrivate methodIUnitOfWorkCoreAddCollectionForSave(IEntityCollectionCore)
Adds the collection with entities for saving. No recursion and no refetch are done for these entities.
Explicit interface implementationPrivate methodIUnitOfWorkCoreAddCollectionForSave(IEntityCollectionCore, Boolean, Boolean)
Adds the collection with entities for saving.
Explicit interface implementationPrivate methodIUnitOfWorkCoreAddForDelete
Adds the passed in entity for deletion.
Explicit interface implementationPrivate methodIUnitOfWorkCoreAddForSave(IEntityCore)
Adds the passed in entity for saving. No refetching will be applied. Save is recursive.
Explicit interface implementationPrivate methodIUnitOfWorkCoreAddForSave(IEntityCore, Boolean)
Adds the passed in entity for saving. No refetching will be applied. Save is recursive.
Explicit interface implementationPrivate methodIUnitOfWorkCoreCommit(ITransactionController)
Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes. This order can be controlled by the constructor of the unit of work which allows users to define a different work order.
Explicit interface implementationPrivate methodIUnitOfWorkCoreCommit(ITransactionController, Boolean)
Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes. This order can be controlled by the constructor of the unit of work which allows users to define a different work order.
Explicit interface implementationPrivate methodIUnitOfWorkCoreCommitAsync
Async variant of Commit(ITransactionController) Commits this unit of work. It will first add all entities in the added collections to the correct bins, then it will start by first inserting all new entities, then saving all updates and then performing the deletes. This order can be controlled by the constructor of the unit of work which allows users to define a different work order.
Explicit interface implementationPrivate methodIUnitOfWorkCoreReset
Resets the inner contents of this Unit of work object
Top
See Also