Class PersistChangesCommand
Base class for commands which persist dataContext changes.
Inheritance
Implements
Inherited Members
Namespace: Kephas.Data.Commands
Assembly: Kephas.Data.dll
Syntax
[DataContextType(typeof(DataContextBase))]
public class PersistChangesCommand : DataCommandBase<IPersistChangesContext, IDataCommandResult>, ILoggable, IPersistChangesCommand, IDataCommand<IPersistChangesContext, IDataCommandResult>, IDataCommand, IAsyncOperation
Constructors
| Improve this Doc View SourcePersistChangesCommand(IDataBehaviorProvider)
Initializes a new instance of the PersistChangesCommand class.
Declaration
public PersistChangesCommand(IDataBehaviorProvider behaviorProvider)
Parameters
Type | Name | Description |
---|---|---|
IDataBehaviorProvider | behaviorProvider | The behavior provider. |
Properties
| Improve this Doc View SourceBehaviorProvider
Gets the behavior provider.
Declaration
public IDataBehaviorProvider BehaviorProvider { get; }
Property Value
Type | Description |
---|---|
IDataBehaviorProvider | The behavior provider. |
Methods
| Improve this Doc View SourceAcceptChanges(IPersistChangesContext, IList<IEntityEntry>)
Accepts the changes of the entities after the persistance.
Declaration
protected virtual void AcceptChanges(IPersistChangesContext operationContext, IList<IEntityEntry> changeSet)
Parameters
Type | Name | Description |
---|---|---|
IPersistChangesContext | operationContext | The operation context. |
System.Collections.Generic.IList<IEntityEntry> | changeSet | The change set. |
ApplyAfterPersistBehaviorsAsync(IPersistChangesContext, IList<IEntityEntry>, CancellationToken)
Applies the behaviors invoking the AfterPersistAsync(Object, IEntityEntry, IDataOperationContext, CancellationToken) asynchronously.
Declaration
protected virtual Task ApplyAfterPersistBehaviorsAsync(IPersistChangesContext operationContext, IList<IEntityEntry> changeSet, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IPersistChangesContext | operationContext | The operation context for persisting the changes. |
System.Collections.Generic.IList<IEntityEntry> | changeSet | The modified entities. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task. |
ApplyBeforePersistBehaviorsAsync(IPersistChangesContext, IList<IEntityEntry>, CancellationToken)
Applies the behaviors invoking the BeforePersistAsync(Object, IEntityEntry, IDataOperationContext, CancellationToken) asynchronously.
Declaration
protected virtual Task ApplyBeforePersistBehaviorsAsync(IPersistChangesContext operationContext, IList<IEntityEntry> changeSet, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IPersistChangesContext | operationContext | The operation context for persisting the changes. |
System.Collections.Generic.IList<IEntityEntry> | changeSet | The modified entities. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task. |
ComputeIterationChangeSet(IPersistChangesContext)
Computes the change set for the current iteration and returns it.
Declaration
protected virtual IList<IEntityEntry> ComputeIterationChangeSet(IPersistChangesContext operationContext)
Parameters
Type | Name | Description |
---|---|---|
IPersistChangesContext | operationContext | The operation context. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<IEntityEntry> | A list of modified IEntityEntry objects. |
ExecuteAsync(IPersistChangesContext, CancellationToken)
Executes the data command asynchronously.
Declaration
public override Task<IDataCommandResult> ExecuteAsync(IPersistChangesContext operationContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IPersistChangesContext | operationContext | The operation context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IDataCommandResult> | A promise of a IDataCommandResult. |
Overrides
PersistChangeSetAsync(IList<IEntityEntry>, IPersistChangesContext, CancellationToken)
Persists the entities in the change set asynchronously.
Declaration
protected virtual Task PersistChangeSetAsync(IList<IEntityEntry> changeSet, IPersistChangesContext operationContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IEntityEntry> | changeSet | The modified entities. |
IPersistChangesContext | operationContext | The data operation context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task. |
PostProcessChangeSetAsync(IList<IEntityEntry>, IPersistChangesContext, CancellationToken)
Post processes the change set asynchronously.
Declaration
protected virtual Task PostProcessChangeSetAsync(IList<IEntityEntry> changeSet, IPersistChangesContext operationContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IEntityEntry> | changeSet | The modified entities. |
IPersistChangesContext | operationContext | The data operation context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task. |
PreProcessChangeSetAsync(IList<IEntityEntry>, IPersistChangesContext, CancellationToken)
Pre processes the change set asynchronously.
Declaration
protected virtual Task PreProcessChangeSetAsync(IList<IEntityEntry> changeSet, IPersistChangesContext operationContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IEntityEntry> | changeSet | The modified entities. |
IPersistChangesContext | operationContext | The data operation context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task. |
Remarks
By default, it sets the PrePersistChangeState to be equal to ChangeState.
ValidateAndPersistChangeSetAsync(IList<IEntityEntry>, Int32, IPersistChangesContext, StringBuilder, CancellationToken)
Validates and persists the modified entities.
Declaration
protected virtual Task<int> ValidateAndPersistChangeSetAsync(IList<IEntityEntry> changeSet, int changes, IPersistChangesContext operationContext, StringBuilder sb, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IEntityEntry> | changeSet | The change set. |
System.Int32 | changes | The changes. |
IPersistChangesContext | operationContext | The data operation context. |
System.Text.StringBuilder | sb | The string builder to append logging data. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | The aggregated number of changes. |
ValidateChangeSetAsync(IList<IEntityEntry>, IPersistChangesContext, CancellationToken)
Validates the modified entries asynchronously.
Declaration
protected virtual Task ValidateChangeSetAsync(IList<IEntityEntry> changeSet, IPersistChangesContext operationContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IEntityEntry> | changeSet | The modified entities. |
IPersistChangesContext | operationContext | The data operation context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task. |
ValidateEntityAsync(Object, IEntityEntry, IPersistChangesContext, CancellationToken)
Validates the modified entity asynchronously.
Declaration
protected virtual Task<IDataValidationResult> ValidateEntityAsync(object entityPart, IEntityEntry entityPartEntry, IPersistChangesContext operationContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Object | entityPart | The entity part. |
IEntityEntry | entityPartEntry | Information describing the entity part. |
IPersistChangesContext | operationContext | The operation context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IDataValidationResult> | A System.Threading.Tasks.Task<TResult>. |