Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

This NuGet package contains a base entity definition along with an entity service which handles the update, delete, add etc. which automatically sets the properties on the base entity and does some basic validation. Every class is extendable, so you can fit it to your needs. The `Add`, `Delete`, `Update`, and `Restore` functions on the entity services are all `virtual`, so you can extend them to fit your needs if you e.g. need more base attributes set automatically.

The class `BaseEntity` is for hard delete entities while `BaseSoftDeleteEntity` is for entities which are only soft deleted. There are repositories for each type of entity as well with mostly the same functionality although the soft delete version has a few extra parameters and also has a restore function.
The class `EntityBase` is for hard delete entities while `EntitySoftDeleteBase` is for entities which are only soft deleted. There are repositories for each type of entity as well with mostly the same functionality although the soft delete version has a few extra parameters and also has a restore function.

## Entities

### BaseEntity
### EntityBase
The base entity contains the following properties:

| Name | Type | Description |
| ---- | ---- | ----------- |
| Id | Guid? | The unique id of the entity |
| Id | TId | The unique id of the entity |
| Created | DateTime | The UTC time for when this entity was created |
| Updated | DateTime | The UTC time for when this entity was last updated |

### BaseSoftDeleteEntities
This class extends `BaseEntity` and adds the following properties:
This class extends `EntityBase` and adds the following properties:

| Name | Type | Description |
| ---- | ---- | ----------- |
Expand All @@ -30,21 +30,21 @@ This is the entity service which handles the communication with the database. Th

| Function | Description |
| -------- | ----------- |
| Get | Fetch a single entity |
| GetList | Get a filtered and possibly paginated list of entities |
| GetListWithSelect | Get a filtered and possibly paginated list of entities where you can specify what properties to return |
| Add | Add a new entity to the DB. The function automatically sets `Created`, `Updated`, and `Id` on the entity |
| Update | Update the provided entity in the DB. The function automatically sets `Updated` |
| Delete | Removes the entity from the DB |
| GetAsync | Fetch a single entity |
| GetListAsync | Get a filtered and possibly paginated list of entities |
| GetListWithSelectAsync | Get a filtered and possibly paginated list of entities where you can specify what properties to return |
| AddAsync | Add a new entity to the DB. The function automatically sets `Created`, `Updated`, and `Id` on the entity |
| UpdateAsync | Update the provided entity in the DB. The function automatically sets `Updated` |
| DeleteAsync | Removes the entity from the DB |

### EntitySoftDeleteRepository
This entity repository handles soft delete entities. It implements the interface `IEntitySoftDeleteRepository` for DI purposes.

For each method in `EntityRepository` where relevant, there are extra parameters for handling soft delete entities e.g. `GetList` where you can choose whether to include deleted in the result list or not (not by default).
For each method in `EntityRepository` where relevant, there are extra parameters for handling soft delete entities e.g. `GetListAsync` where you can choose whether to include deleted in the result list or not (not by default).

Along with the methods from `EntityRepository`, this repository implements the following extra methods along with changed behaviour on `Delete`:
Along with the methods from `EntityRepository`, this repository implements the following extra methods along with changed behaviour on `DeleteAsync` including extra parameters regarding to soft delete behaviour on the other functions:

| Function | Description |
| -------- | ----------- |
| Delete | Soft delete the entity. Sets `Deleted` to `true` and sets `Deleted` as well |
| Restore | Undelete the entity. Sets `Deleted` to `false` and sets `DeletedAt` to `null` |
| DeleteAsync | Soft delete the entity. Sets `Deleted` to `true` and sets `Deleted` as well |
| RestoreAsync | Undelete the entity. Sets `Deleted` to `false` and sets `DeletedAt` to `null` |