From 1063719ca6f21afb6f4a1695ce6d890deb2d2ebb Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Thu, 12 Aug 2021 22:37:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=94=B9=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E4=B8=AA=E5=9B=9E=E8=B0=83=E5=8F=82=E6=95=B0=E4=B8=BA?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Dynamic/DataTableDynamicContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs b/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs index ee2012a31..45ce74338 100644 --- a/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs +++ b/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs @@ -39,7 +39,7 @@ namespace BootstrapBlazor.Components /// /// /// - public DataTableDynamicContext(DataTable table, Action? addAttributesCallback) + public DataTableDynamicContext(DataTable table, Action? addAttributesCallback = null) { DataTable = table; AddAttributesCallback = addAttributesCallback; -- Gitee From 1891463b33928fe526388aa805c2390a27438721 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Thu, 12 Aug 2021 22:37:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E5=AF=B9=20DBNull?= =?UTF-8?q?=20=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Dynamic/DataTableDynamicContext.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs b/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs index 45ce74338..33b488d3a 100644 --- a/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs +++ b/src/BootstrapBlazor/Components/Table/Dynamic/DataTableDynamicContext.cs @@ -65,7 +65,12 @@ namespace BootstrapBlazor.Components foreach (DataColumn col in DataTable.Columns) { var invoker = SetPropertyCache.GetOrAdd((dynamicObject.GetType(), col.ColumnName), key => LambdaExtensions.SetPropertyValueLambda(dynamicObject, key.PropertyName).Compile()); - invoker.Invoke(dynamicObject, row[col]); + var v = row[col]; + if (row.IsNull(col)) + { + v = null; + } + invoker.Invoke(dynamicObject, v); } if (dynamicObject is IDynamicObject d) { @@ -78,7 +83,7 @@ namespace BootstrapBlazor.Components return Items.Value; } - private ConcurrentDictionary<(Type ModelType, string PropertyName), Action> SetPropertyCache { get; } = new(); + private ConcurrentDictionary<(Type ModelType, string PropertyName), Action> SetPropertyCache { get; } = new(); /// /// GetItems 方法 -- Gitee