Interface ISqlDatabaseChangeTracker
Represents a tracker of changes applied to the attached database builder.
public interface ISqlDatabaseChangeTracker
- Extension Methods
Properties
ActionTimeout
Optional CommandTimeout for registered SqlDatabaseBuilderCommandAction instances.
TimeSpan? ActionTimeout { get; }
Property Value
ActiveObject
Represents a currently tracked SQL object builder instance, whose changes will be aggregated.
ISqlObjectBuilder? ActiveObject { get; }
Property Value
ActiveObjectExistenceState
Specifies the existence state of ActiveObject.
SqlObjectExistenceState ActiveObjectExistenceState { get; }
Property Value
Database
Database that this instance tracks.
ISqlDatabaseBuilder Database { get; }
Property Value
IsAttached
Specifies whether or not this change tracker is attached.
bool IsAttached { get; }
Property Value
Remarks
Change tracker will ignore all changes when IsAttached is equal to false.
Mode
Specifies the current SqlDatabaseCreateMode.
SqlDatabaseCreateMode Mode { get; }
Property Value
Remarks
Methods
AddAction(Action<IDbCommand>, Action<IDbCommand>?)
Adds a custom SqlDatabaseBuilderCommandAction to this change tracker.
ISqlDatabaseChangeTracker AddAction(Action<IDbCommand> action, Action<IDbCommand>? setup = null)
Parameters
action
Action<IDbCommand>Custom delegate that executes the IDbCommand.
setup
Action<IDbCommand>Optional delegate that prepares the IDbCommand. Can be used to e.g. prepare a collection of parameters. Equal to null by default.
Returns
AddParameterizedStatement(ISqlStatementNode, IEnumerable<SqlParameter>, SqlParameterBinderCreationOptions?)
Adds a custom parameterized SQL statement
to this change tracker.
ISqlDatabaseChangeTracker AddParameterizedStatement(ISqlStatementNode statement, IEnumerable<SqlParameter> parameters, SqlParameterBinderCreationOptions? options = null)
Parameters
statement
ISqlStatementNodeSQL statement node to add.
parameters
IEnumerable<SqlParameter>Source of parameters to bind.
options
SqlParameterBinderCreationOptions?Optional SqlParameterBinderCreationOptions.
Returns
AddParameterizedStatement<TSource>(ISqlStatementNode, TSource, SqlParameterBinderCreationOptions?)
Adds a custom parameterized SQL statement
to this change tracker.
ISqlDatabaseChangeTracker AddParameterizedStatement<TSource>(ISqlStatementNode statement, TSource parameters, SqlParameterBinderCreationOptions? options = null) where TSource : notnull
Parameters
statement
ISqlStatementNodeSQL statement node to add.
parameters
TSourceSource of parameters to bind.
options
SqlParameterBinderCreationOptions?Optional SqlParameterBinderCreationOptions.
Returns
Type Parameters
TSource
Parameter source type.
AddStatement(ISqlStatementNode)
Adds a custom SQL statement
to this change tracker.
ISqlDatabaseChangeTracker AddStatement(ISqlStatementNode statement)
Parameters
statement
ISqlStatementNodeSQL statement node to add.
Returns
Exceptions
- SqlObjectBuilderException
When
statement
contains parameters.
Attach(bool)
Changes IsAttached value for this change tracker.
ISqlDatabaseChangeTracker Attach(bool enabled = true)
Parameters
enabled
boolValue to set. Equal to true by default.
Returns
CompletePendingChanges()
Completes all pending changes and registers appropriate SqlDatabaseBuilderCommandAction instances for them.
ISqlDatabaseChangeTracker CompletePendingChanges()
Returns
ContainsChange(ISqlObjectBuilder, SqlObjectChangeDescriptor)
Checks whether or not a change for the given target
and its property's descriptor
is currently pending.
[Pure]
bool ContainsChange(ISqlObjectBuilder target, SqlObjectChangeDescriptor descriptor)
Parameters
target
ISqlObjectBuilderObject to check.
descriptor
SqlObjectChangeDescriptorProperty change descriptor.
Returns
- bool
true when the change is pending, otherwise false.
GetExistenceState(ISqlObjectBuilder)
Returns SqlObjectExistenceState value for the given ISqlObjectBuilder instance.
[Pure]
SqlObjectExistenceState GetExistenceState(ISqlObjectBuilder target)
Parameters
target
ISqlObjectBuilderObject to check.
Returns
- SqlObjectExistenceState
One of three possible values:
Remarks
Use ActiveObjectExistenceState instead, for reading current state of the ActiveObject.
GetPendingActions()
Returns a collection of all pending SqlDatabaseBuilderCommandAction instances.
ReadOnlySpan<SqlDatabaseBuilderCommandAction> GetPendingActions()
Returns
- ReadOnlySpan<SqlDatabaseBuilderCommandAction>
Collection of all pending SqlDatabaseBuilderCommandAction instances.
SetActionTimeout(TimeSpan?)
Changes ActionTimeout value for this change tracker.
ISqlDatabaseChangeTracker SetActionTimeout(TimeSpan? value)
Parameters
value
TimeSpan?Value to set.
Returns
TryGetOriginalValue(ISqlObjectBuilder, SqlObjectChangeDescriptor, out object?)
Attempts to return a value before the change associated with the given target
and its property's descriptor
.
bool TryGetOriginalValue(ISqlObjectBuilder target, SqlObjectChangeDescriptor descriptor, out object? result)
Parameters
target
ISqlObjectBuilderObject to check.
descriptor
SqlObjectChangeDescriptorProperty change descriptor.
result
objectout parameter that returns the value before the change was made.
Returns
- bool
true when the change is pending and original value was retrieved, otherwise false.