SoftDelete 1.3.0
dotnet add package SoftDelete --version 1.3.0
NuGet\Install-Package SoftDelete -Version 1.3.0
<PackageReference Include="SoftDelete" Version="1.3.0" />
paket add SoftDelete --version 1.3.0
#r "nuget: SoftDelete, 1.3.0"
// Install SoftDelete as a Cake Addin #addin nuget:?package=SoftDelete&version=1.3.0 // Install SoftDelete as a Cake Tool #tool nuget:?package=SoftDelete&version=1.3.0
Ef Core Soft Delete implementation
A very simple implementation for soft deleting entities in Ef Core library.
Note:
EFCore.SoftDelete and SoftDelete are both based on this repository, both will get updates and will be maintained
Usage:
Step 1:
Extend your application db context from SoftDeletes.Core.DbContext
.
Step 2:
In entities you want to add soft delete support, implement SoftDeletes.ModelTools.ISoftDelete
interface.
It will a column named DeletedAt
to your entity so you need to add a migration and update the database tables.
Step 3:
Load relations you want to delete in soft deleting the entity in LoadRelationsAsync
and LoadRelations
methods.
Step 4:
Delete relations you want to delete in soft deleting the entity in OnSoftDeleteAsync
and OnSoftDelete
methods.
Step 5:
For soft deleting an entity use Remove
and RemoveAsync
methods. These methods will
soft delete an ISoftDelete
implemented entity and force delete an not implemented entity.
For force deleting any entity use ForceRemove
method.
Step 6:
For restoring soft-deleted entities, you can use Restore
and RestoreAsync
methods.
Note that this methods will no longer call SaveChanges
method. For better performance, you should manually call SaveChanges
method.
Important Note:
It doesn't support DbSet
yet, so you have to use SoftDeletes.Core.DbContext
methods for removing instead of using DbSet
methods.
Extra:
ITimestamps
interface:
An interface for saving CreatedAt
and UpdatedAt
date and time of entities.
You can implement it in your entities. That will add to columns named
CreatedAt
and UpdatedAt
to your entities.
ModelExtenstion
abstract class:
An abstract class that implements ITimestamps
and ISoftDelete
interfaces.
You can use it in your entities.
Demo:
sample project for this implementation.
Donation:
If you like it, you can support me with USDT
:
TJ57yPBVwwK8rjWDxogkGJH1nF3TGPVq98
forUSDT TRC20
0x743379201B80dA1CB680aC08F54b058Ac01346F1
forUSDT ERC20
Proposal:
The proposal for this implementation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.EntityFrameworkCore (>= 6.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SoftDelete:
Package | Downloads |
---|---|
ReportSharp
Crash and information reporter for dotnet |
GitHub repositories
This package is not used by any popular GitHub repositories.