Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit e7b19da

Browse files
author
Morten Turn Pedersen
committed
Updated documentation
1 parent 343e42f commit e7b19da

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,50 @@
11
# Entity Framework Base Package
22

3-
This NuGet package contains a base entity definition along with an entity service which handles the update, soft 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 service are all `virtual`, so you can extend them to fit your needs if you e.g. need more base attributes set automatically.
3+
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.
44

5-
## BaseEntity
5+
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.
6+
7+
## Entities
8+
9+
### BaseEntity
610
The base entity contains the following properties:
711

812
| Name | Type | Description |
913
| ---- | ---- | ----------- |
1014
| Id | Guid? | The unique id of the entity |
1115
| Created | DateTime | The UTC time for when this entity was created |
1216
| Updated | DateTime | The UTC time for when this entity was last updated |
17+
18+
### BaseSoftDeleteEntities
19+
This class extends `BaseEntity` and adds the following properties:
20+
21+
| Name | Type | Description |
22+
| ---- | ---- | ----------- |
1323
| DeletedAt | DateTime? | The UTC time for when this entity was soft deleted |
1424
| Deleted | bool | Whether the entity is deleted or not |
1525

16-
## EntityRepository
26+
## Repositories
27+
28+
### EntityRepository
1729
This is the entity service which handles the communication with the database. There is also an interface `IEntityRepository`, so you can use DI to inject it into your code.
1830

1931
| Function | Description |
2032
| -------- | ----------- |
2133
| Get | Fetch a single entity |
2234
| GetList | Get a filtered and possibly paginated list of entities |
35+
| GetListWithSelect | Get a filtered and possibly paginated list of entities where you can specify what properties to return |
2336
| Add | Add a new entity to the DB. The function automatically sets `Created`, `Updated`, and `Id` on the entity |
2437
| Update | Update the provided entity in the DB. The function automatically sets `Updated` |
38+
| Delete | Removes the entity from the DB |
39+
40+
### EntitySoftDeleteRepository
41+
This entity repository handles soft delete entities. It implements the interface `IEntitySoftDeleteRepository` for DI purposes.
42+
43+
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).
44+
45+
Along with the methods from `EntityRepository`, this repository implements the following extra methods along with changed behaviour on `Delete`:
46+
47+
| Function | Description |
48+
| -------- | ----------- |
2549
| Delete | Soft delete the entity. Sets `Deleted` to `true` and sets `Deleted` as well |
2650
| Restore | Undelete the entity. Sets `Deleted` to `false` and sets `DeletedAt` to `null` |

0 commit comments

Comments
 (0)