aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-12-13 11:14:30 +0800
committercrupest <crupest@outlook.com>2022-12-20 20:32:53 +0800
commite42b048abf6c97515686c42175c29191b1527dfd (patch)
tree9d2c97e517a36644ac5069469249475a17310433 /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md
parentbc2a3db855cca16d4f66b23f814528671b5d8591 (diff)
downloadcrupest-e42b048abf6c97515686c42175c29191b1527dfd.tar.gz
crupest-e42b048abf6c97515686c42175c29191b1527dfd.tar.bz2
crupest-e42b048abf6c97515686c42175c29191b1527dfd.zip
Develop secret api. v33
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md')
-rw-r--r--docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md27
1 files changed, 20 insertions, 7 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md
index 589b0a8..22289cb 100644
--- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md
+++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md
@@ -10,20 +10,33 @@ The ultimate CRUD scaffold finally comes.
1. Create select `what`, where clause, order clause, `Offset` and `Limit`.
2. Check clauses' related columns are valid. Then generate sql string and param list.
-3. Convert param list to `Dapper` dynamic params. Execute sql and get `dynamic`s.
-4. Run hook `AfterSelect` for every column.
+3. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. Execute sql and get `dynamic`s.
+4. For each column:
+ 1. If column not in query result is null, null will be used to call hooks.
+ 2. If column is `NULL`, `DbNullValue` will be used to call hooks.
+ 3. Otherwise run conversion in `IColumnTypeInfo`.
+ 4. Run hook `AfterSelect` for every column.
5. Convert `dynamic`s to `TEntity`s.
### Insert
1. Create insert clause consisting of insert items.
2. Check clauses' related columns are valid. Then generate sql string and param list.
-3. Run hook `BeforeInsert` for every column.
-4. Convert param list to `Dapper` dynamic params. Execute sql and return `KeyColumn` value.
+3. For each column:
+ 1. If insert item exits and value is not null but the column `IsGenerated` is true, throw exception.
+ 2. If insert item does not exist or value is `null` for that column, use default value generator to generate value. However, `DbNullValue` always means use `NULL` for that column.
+ 3. Coerce null to `DbNullValue`.
+ 4. Run hook `BeforeInsert`.
+ 5. Coerce null to `DbNullValue`.
+ 6. Run validator.
+4. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. Execute sql and return `KeyColumn` value.
### Update
-1. Create update clause consisting of update items, where clause.
+1. Create update clause consisted of update items, where clause.
2. Check clauses' related columns are valid. Then generate sql string and param list.
-3. Run hook `BeforeUpdate` for every column.
-4. Convert param list to `Dapper` dynamic params. Execute sql and get count of affected rows.
+3. For each column:
+ 1. If insert item does not exist, `null` will be used to call hooks. However, `DbNullValue` always means use `NULL` for that column.
+ 2. Run hook `BeforeInsert`. If value is null, it means do not update this column.
+ 3. Run validator if `value` is not null.
+4. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. Execute sql and get count of affected rows.