aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-12-11 11:12:29 +0800
committercrupest <crupest@outlook.com>2022-12-20 20:32:53 +0800
commit8243498d2a201616239c6f4c48fa68737175978c (patch)
tree3dbe79a875e9f7d602cba6e551c69193cadaf1ea /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/TableInfo.cs
parentbd523a6a7cac09fe580223c3d75e41e1e100f603 (diff)
downloadcrupest-8243498d2a201616239c6f4c48fa68737175978c.tar.gz
crupest-8243498d2a201616239c6f4c48fa68737175978c.tar.bz2
crupest-8243498d2a201616239c6f4c48fa68737175978c.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.cs30
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);