Definition
Assembly: CloudNimble.EasyAF.Business.EF6.dll Namespace: CloudNimble.EasyAF.Business Inheritance: CloudNimble.EasyAF.Business.ManagerBase<TContext>Syntax
Summary
Provides a base class for entity-specific business logic managers with built-in CRUD operations, audit trail support, and lifecycle event hooks. Handles common entity operations and automatically manages audit fields for entities that implement auditing interfaces.Remarks
This manager provides comprehensive entity lifecycle management including:- Automatic audit trail creation for entities implementing ICreatedAuditable, IUpdatedAuditable
- User tracking for entities implementing
ICreatorTrackable1,IUpdaterTrackable1 - Virtual hooks for custom business logic before and after CRUD operations
- Batch operations support for improved performance
- Thread-safe interface caching for performance optimization
Type Parameters
TContext- The type of DbContext used for database operations.TEntity- The type of entity managed by this manager.
Examples
Constructors
.ctor
Initializes a new instance of theEntityManager2` class.
Syntax
Parameters
.ctor Inherited
Inherited from
CloudNimble.EasyAF.Business.ManagerBase<TContext>ManagerBase1` class.
Syntax
Parameters
.ctor Inherited
Inherited from
objectSyntax
Properties
DataContext Inherited
Inherited from
CloudNimble.EasyAF.Business.ManagerBase<TContext>Syntax
Property Value
Type:TContext
MessagePublisher Inherited
Inherited from
CloudNimble.EasyAF.Business.ManagerBase<TContext>Syntax
Property Value
Type:CloudNimble.SimpleMessageBus.Publish.IMessagePublisher
Methods
DeleteAsync
Delete a specific DbSet`1 with optional save operation.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
DeleteAsync
Delete a specific DbSet`1 with optional save operation using a specified DbContext.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
DeleteAsync
Delete all DbSet`1 from a list with optional save operation.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
Remarks
RWM: This will need to be Deleted to be generic if it’s going to be in a NuGet package.DeleteAsync
Delete all DbSet`1 from a list with optional save operation using a specified DbContext.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
DirectDelete
Delete entities returned by the specified query without individual entity processing.Syntax
Parameters
Returns
Type:int
Remarks
This overload will give you all of the performance of deleting a set of data without loading entities in the context but none of the extra processing provided by OnDeleting / OnDeleted.DirectDeleteAsync
Delete entities returned by the specified query without individual entity processing.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<int>
Remarks
This overload will give you all of the performance of deleting a set of data without loading entities in the context but none of the extra processing provided by OnDeleting / OnDeleted.DirectUpdate
Executes a direct UPDATE query on the database without returning objects or processing them through the interceptors.Syntax
Parameters
Returns
Type:int
Remarks
This overload will give you all of the performance of updating a set of data without loading entities in the context but none of the extra processing provided by OnUpdating / OnUpdated.DirectUpdateAsync
Executes a direct UPDATE query on the database without returning objects or processing them through the interceptors.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<int>
Remarks
This overload will give you all of the performance of updating a set of data without loading entities in the context but none of the extra processing provided by OnUpdating / OnUpdated.Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
InsertAsync
Inserts a single entity into the database with optional save operation. Executes the OnInsertingAsync and OnInsertedAsync lifecycle hooks.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entity was successfully inserted; otherwise, false.
Remarks
RWM: This will need to be updated to be generic if it’s going to be in a NuGet package.InsertAsync
Inserts a single entity into the database using a specified context with optional save operation. Executes the OnInsertingAsync and OnInsertedAsync lifecycle hooks.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entity was successfully inserted; otherwise, false.
InsertAsync
Inserts a collection of entities into the database with optional save operation. Executes the OnInsertingAsync and OnInsertedAsync lifecycle hooks for each entity.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entities were successfully inserted; otherwise, false.
Remarks
RWM: This will need to be updated to be generic if it’s going to be in a NuGet package.InsertAsync
Inserts a collection of entities into the database using a specified context with optional save operation. Executes the OnInsertingAsync and OnInsertedAsync lifecycle hooks for each entity.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entities were successfully inserted; otherwise, false.
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
OnDeletedAsync Virtual
Called after successfully deleting an entity from the database. Use this method for post-deletion business logic such as cleanup operations, sending notifications, or triggering external systems.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if post-deletion processing was successful; otherwise, false.
OnDeletedAsync Virtual
Called after successfully deleting a collection of entities from the database. Applies OnDeletedAsync logic to each entity in the collection.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
OnDeletingAsync Virtual
Called before deleting an entity from the database. Override this method to add custom business logic or validation before deletion.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
OnDeletingAsync Virtual
Called before deleting a collection of entities from the database. Applies OnDeletingAsync logic to each entity in the collection.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
OnInsertedAsync Virtual
Called after successfully inserting an entity into the database. Use this method for post-insertion business logic such as sending notifications, publishing events, or triggering external systems.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if post-insertion processing was successful; otherwise, false.
OnInsertedAsync Virtual
Called after successfully inserting a collection of entities into the database. Applies OnInsertedAsync logic to each entity in the collection.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
OnInsertingAsync Virtual
Called before inserting an entity into the database. Automatically handles audit field population and user tracking for entities implementing the appropriate interfaces.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
Remarks
This method automatically sets:- CreatedById for entities implementing
ICreatorTrackable1` - DateCreated for entities implementing ICreatedAuditable Override this method to add custom business logic before insertion.
OnInsertingAsync
Called before inserting a collection of entities into the database. Applies OnInsertingAsync logic to each entity in the collection.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
OnUpdatedAsync Virtual
Called after successfully updating an entity in the database. Use this method for post-update business logic such as sending notifications, publishing events, or triggering external systems.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if post-update processing was successful; otherwise, false.
OnUpdatedAsync Virtual
Called after successfully updating a collection of entities in the database. Applies OnUpdatedAsync logic to each entity in the collection.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
OnUpdatingAsync Virtual
Called before updating an entity in the database. Automatically handles audit field population and user tracking for entities implementing the appropriate interfaces.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
Remarks
This method automatically sets:- UpdatedById for entities implementing
IUpdaterTrackable1` - DateUpdated for entities implementing IUpdatedAuditable Override this method to add custom business logic before updating.
OnUpdatingAsync Virtual
Called before updating a collection of entities in the database. Applies OnUpdatingAsync logic to each entity in the collection.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ResetAuditProperties
Resets audit properties to an “Inserted” state by setting creation fields and clearing update fields. Sets CreatedById and DateCreated to current values, while clearing UpdatedById and DateUpdated.Syntax
Parameters
Type Parameters
TDbObservable- Any DbObservableObject in the object model. DOES NOT have to be the entity for this Manager.
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
UpdateAsync
Updates a single entity in the database with optional save operation. Executes the OnUpdatingAsync and OnUpdatedAsync lifecycle hooks.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entity was successfully updated; otherwise, false.
Remarks
RWM: This will need to be updated to be generic if it’s going to be in a NuGet package.UpdateAsync
Updates a single entity in the database using a specified context with optional save operation. Executes the OnUpdatingAsync and OnUpdatedAsync lifecycle hooks.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entity was successfully updated; otherwise, false.
UpdateAsync
Updates a collection of entities in the database with optional save operation. Executes the OnUpdatingAsync and OnUpdatedAsync lifecycle hooks for each entity.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entities were successfully updated; otherwise, false.
Remarks
RWM: This will need to be updated to be generic if it’s going to be in a NuGet package.UpdateAsync
Updates a collection of entities in the database using a specified context with optional save operation. Executes the OnUpdatingAsync and OnUpdatedAsync lifecycle hooks for each entity.Syntax
Parameters
Returns
Type:System.Threading.Tasks.Task<bool>
True if the entities were successfully updated; otherwise, false.