mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-03 12:39:40 +08:00
!1715 feat(#I458DK): DynamicDataTableContext add DBNull process logic
* fix: 增加对 DBNull 的处理逻辑 * feat: 更改第二个回调参数为可选参数
This commit is contained in:
parent
c8fe737903
commit
97d239e1e4
@ -39,7 +39,7 @@ namespace BootstrapBlazor.Components
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="addAttributesCallback"></param>
|
||||
public DataTableDynamicContext(DataTable table, Action<DataTableDynamicContext, ITableColumn>? addAttributesCallback)
|
||||
public DataTableDynamicContext(DataTable table, Action<DataTableDynamicContext, ITableColumn>? addAttributesCallback = null)
|
||||
{
|
||||
DataTable = table;
|
||||
AddAttributesCallback = addAttributesCallback;
|
||||
@ -65,7 +65,12 @@ namespace BootstrapBlazor.Components
|
||||
foreach (DataColumn col in DataTable.Columns)
|
||||
{
|
||||
var invoker = SetPropertyCache.GetOrAdd((dynamicObject.GetType(), col.ColumnName), key => LambdaExtensions.SetPropertyValueLambda<object, object?>(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<object, object>> SetPropertyCache { get; } = new();
|
||||
private ConcurrentDictionary<(Type ModelType, string PropertyName), Action<object, object?>> SetPropertyCache { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// GetItems 方法
|
||||
|
Loading…
Reference in New Issue
Block a user