diff options
author | crupest <crupest@outlook.com> | 2022-12-13 16:44:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-12-20 20:32:53 +0800 |
commit | 37ccef55ad134cc10e91d82fe6b60286daf644cc (patch) | |
tree | b646eaa164b4b2fc5f712ceddbb92b2b67865295 /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md | |
parent | 9a2e48b64befc039b71ec6fff9b58060ca1d1268 (diff) | |
download | crupest-37ccef55ad134cc10e91d82fe6b60286daf644cc.tar.gz crupest-37ccef55ad134cc10e91d82fe6b60286daf644cc.tar.bz2 crupest-37ccef55ad134cc10e91d82fe6b60286daf644cc.zip |
Develop secret api. v36
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md index 22289cb..ca8a6f1 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md @@ -9,34 +9,34 @@ The ultimate CRUD scaffold finally comes. ### Select 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 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. +2. Check clauses' related columns are valid. +3. Generate sql string and param list. +4. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. +5. Execute sql and get `dynamic`s. +6. (Optional) 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. +1. Create insert clause. +2. Check clauses' related columns are valid. 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. + 1. If insert item exists and value is not null but the column `IsGenerated` is true, throw exception. + 2. If insert item does not exist or value is `null`, 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. + 4. Run validator to validate the value. + 5. If value is `DbNullValue`, `IsNotNull` is true and `IsAutoIncrement` is false, throw exception. +4. Generate sql string and param list. +5. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. +6. Execute sql and return `KeyColumn` value. ### Update -1. Create update clause consisted of update items, where clause. +1. Create update clause, where clause. 2. Check clauses' related columns are valid. Then generate sql string and param list. 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. + 1. If update item exists and value is not null but the column `IsNoUpdate` is true, throw exception. + 2. Invoke validator to validate the value. + 3. If `IsNotNull` is true and value is `DbNullValue`, throw exception. +4. Generate sql string and param list. +5. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. +6. Execute sql and return count of affected rows. |