From 4fe8d1c88cafd86950e41ae81b94c0d1790e7dfa Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 13 Dec 2022 17:17:06 +0800 Subject: Develop secret api. v37 --- .../CrupestApi/CrupestApi.Commons/Crud/README.md | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md') diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md index ca8a6f1..b008ea7 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/README.md @@ -19,24 +19,29 @@ The ultimate CRUD scaffold finally comes. 1. Create insert clause. 2. Check clauses' related columns are valid. -3. For each column: +3. Create a real empty insert clause. +4. For each 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 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. + 3. If value is `null` and the column `IsAutoIncrement` is true, skip to next column. + 4. Coerce null to `DbNullValue`. + 5. Run validator to validate the value. + 6. If value is `DbNullValue`, `IsNotNull` is true, throw exception. + 7. Add column and value to real insert clause. +5. Generate sql string and param list. +6. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. +7. Execute sql and return `KeyColumn` value. ### Update 1. Create update clause, where clause. 2. Check clauses' related columns are valid. Then generate sql string and param list. -3. For each column: +3. Create a real empty update clause. +4. For each column: 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. + 4. Add column and value to real update clause. +5. Generate sql string and param list. +6. Convert param list to `Dapper` dynamic params with proper type conversion in `IColumnTypeInfo`. +7. Execute sql and return count of affected rows. -- cgit v1.2.3