From 81f9571072a7978fe8b65dd9645d30e351138acd Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 12 Dec 2022 20:30:55 +0800 Subject: Develop secret api. v31 --- .../CrupestApi.Commons/Crud/ColumnInfo.cs | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs') diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs index 37ae971..6e29de0 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs @@ -19,14 +19,41 @@ public class ColumnHooks BeforeUpdate = beforeUpdate; } - /// Called after SELECT. Please use multicast if you want to customize it because there are many default behavior in it.Called after SELECT. Please use multicast if you want to customize it because there are many default behavior in it. + /// + /// value(in): + /// null => not found in SELECT result + /// DbNullValue => database NULL + /// others => database value + /// value(out): + /// null/DbNullValue => return null + /// others => return as is + /// public ColumnHookAction AfterSelect; /// Called before INSERT. Please use multicast if you want to customize it because there are many default behavior in it. + /// + /// value(in): + /// null => not specified by insert clause + /// DbNullValue => specified as database NULL + /// other => specified as other value + /// value(out): + /// null/DbNullValue => save database NULL + /// other => save the value as is + /// public ColumnHookAction BeforeInsert; /// Called before UPDATE. Please use multicast if you want to customize it because there are many default behavior in it.Set value to null to delete the update item so it will not change. Set value to to update the column to NULL. + /// + /// value(in): + /// null => not specified by update clause + /// DbNullValue => specified as database NULL + /// other => specified as other value + /// value(out): + /// null => not update + /// DbNullValue => update to database NULL + /// other => update to the value + /// public ColumnHookAction BeforeUpdate; } @@ -86,7 +113,7 @@ public class ColumnInfo public bool IsPrimaryKey => Metadata.GetValueOrDefault(ColumnMetadataKeys.IsPrimaryKey) is true; public bool IsAutoIncrement => Metadata.GetValueOrDefault(ColumnMetadataKeys.IsAutoIncrement) is true; public bool IsNotNull => IsPrimaryKey || Metadata.GetValueOrDefault(ColumnMetadataKeys.NotNull) is true; - public bool IsClientGenerate => Metadata.GetValueOrDefault(ColumnMetadataKeys.ClientGenerate) is true; + public bool IsGenerated => Metadata.GetValueOrDefault(ColumnMetadataKeys.Generated) is true; public bool IsNoUpdate => Metadata.GetValueOrDefault(ColumnMetadataKeys.NoUpdate) is true; /// /// This only returns metadata value. It doesn't not fall back to primary column. If you want to get the real key column, go to table info. @@ -148,7 +175,7 @@ public class ColumnInfo protected void OnBeforeInsert(ColumnInfo column, ref object? value) { - if (column.IsClientGenerate && value is not null) + if (column.IsGenerated && value is not null) { throw new Exception($"'{column.ColumnName}' can't be set manually. It is auto generated."); } -- cgit v1.2.3