diff options
author | crupest <crupest@outlook.com> | 2022-12-11 11:12:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-12-20 20:32:53 +0800 |
commit | d31b8cfd9107bba6ed375e845b1ccefacda93d11 (patch) | |
tree | 3dbe79a875e9f7d602cba6e551c69193cadaf1ea /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs | |
parent | 2c7e3b1c00dc13ab3647d960a79d1d7b5ba6c362 (diff) | |
download | crupest-d31b8cfd9107bba6ed375e845b1ccefacda93d11.tar.gz crupest-d31b8cfd9107bba6ed375e845b1ccefacda93d11.tar.bz2 crupest-d31b8cfd9107bba6ed375e845b1ccefacda93d11.zip |
Develop secret api. v27
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs index 93d02fd..d2f48c6 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs @@ -1,5 +1,4 @@ using System.Data; -using System.Diagnostics; using System.Reflection; using System.Text; using Dapper; @@ -368,7 +367,12 @@ CREATE TABLE {tableName}( var result = new DynamicParameters(); foreach (var param in parameters) { - if (param.Value is null || param.Value is DbNullValue) + if (param.Value is null) + { + continue; + } + + if (param.Value is DbNullValue) { result.Add(param.Name, null); continue; @@ -418,10 +422,17 @@ CREATE TABLE {tableName}( { object? value = null; var dynamicProperty = dynamicType.GetProperty(column.ColumnName); - if (dynamicProperty is not null) value = dynamicProperty.GetValue(d); - if (value is not null) - value = column.ColumnType.ConvertFromDatabase(value); - column.Hooks.AfterSelect(column, ref value); + if (dynamicProperty is null) + { + column.Hooks.AfterSelect(column, ref value, false); + } + else + { + value = dynamicProperty.GetValue(d); + if (value is not null) + value = column.ColumnType.ConvertFromDatabase(value); + column.Hooks.AfterSelect(column, ref value, true); + } var propertyInfo = column.PropertyInfo; if (propertyInfo is not null) { @@ -443,8 +454,11 @@ CREATE TABLE {tableName}( foreach (var column in ColumnInfos) { InsertItem? item = insert.Items.FirstOrDefault(i => i.ColumnName == column.ColumnName); - var value = item?.Value; - column.Hooks.BeforeInsert(column, ref value); + object? value = null; + if (item is null || item.Value is null) + { + column.Hooks.BeforeInsert(column, , ); + } if (item is null) { item = new InsertItem(column.ColumnName, value); |