EntityDbExtensions 1.0.0
See the version list below for details.
dotnet add package EntityDbExtensions --version 1.0.0
NuGet\Install-Package EntityDbExtensions -Version 1.0.0
<PackageReference Include="EntityDbExtensions" Version="1.0.0" />
paket add EntityDbExtensions --version 1.0.0
#r "nuget: EntityDbExtensions, 1.0.0"
// Install EntityDbExtensions as a Cake Addin
#addin nuget:?package=EntityDbExtensions&version=1.0.0
// Install EntityDbExtensions as a Cake Tool
#tool nuget:?package=EntityDbExtensions&version=1.0.0
EntityDbExtensions
Simplify Entity Framework Delete Child Operations
Overview
Tired of manual and repetitive code when it comes to deleting child and subsequent objects with validations and nested loops? This library simplifies the process for you. By simply invoking a method in the .Update of the root class, it will automatically handle the recursive deletion of all child, grandchild, and subsequent objects that have been removed from your root class.
The method will inspect classes containing a virtual child property with a generic list type, such as IEnumerable<YourClass> or ICollection<YourClass>.
public virtual IEnumerable<YourChild> YourChild { get; private set; }
It performs a validation check to determine if the object has been deleted, marking it as removed. This marking signals Entity Framework to handle the deletion seamlessly. The validation process is recursive, ensuring that all child and subsequent objects undergo thorough examination and validation for removal.
Features
Effortless Database Operations: Streamline your Entity Framework database operations with simplified methods.
Extension Methods for DbContext: Easily perform common database operations using intuitive extension methods on your DbContexts.
Getting Started
- Installation:
- Install the EntityDbExtensions NuGet package in your .NET project.
dotnet add package EntityDbExtensions
Usage:
Add the necessary using statement to your code.
Start using the extension methods on your Entity Framework entities.
using EntityDbExtensions;
public async Task<bool> Update(YourEntity entity)
{
var entityDb = await Get(entity.Id);
_yourDbContext.HandleDeletedChildren(entity, entityDb); // Here the magic happens.
_yourDbContext.Set<YourEntity>().Update(entity);
return await _yourDbContext.SaveChangesAsync() > 0;
}
Contribution
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.
License
This project is licensed under the MIT License.
LinkedIn - ( https://www.linkedin.com/in/alan-evandro-barboza/ )
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.0.0:
- Initial release of EntityDbExtensions.
- Simplifies recursive deletion of child and subsequent objects.
- Supports virtual child properties with generic list types.
- Seamless integration with Entity Framework and Entity Framework Core.
- Provides a more efficient and automated way to handle object deletions.