Skip to content

Commit f9aa99e

Browse files
authored
fix(Table): support value type (#7307)
* fix: 兼容值类型数据 * chore: bump version 10.1.4-beta04
1 parent 81ca44c commit f9aa99e

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.1.4-beta03</Version>
4+
<Version>10.1.4-beta04</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Extensions/LambdaExtensions.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,17 @@ private static ConditionalExpression BuildPropertyAccess(Expression instance, Ty
676676
var p = instanceType.GetPropertyByName(propertyName) ?? throw new InvalidOperationException($"类型 {instanceType.Name} 未找到 {propertyName} 属性,无法获取其值");
677677

678678
var propertyAccess = Expression.Property(instance, p);
679-
return Expression.Condition(
680-
test: Expression.Equal(instance, Expression.Constant(null, instanceType)),
681-
ifTrue: Expression.Constant(null, p.PropertyType),
682-
ifFalse: propertyAccess
683-
);
679+
return p.PropertyType.IsValueType
680+
? Expression.Condition(
681+
test: Expression.Equal(instance, Expression.Constant(null, instanceType)),
682+
ifTrue: Expression.Default(p.PropertyType),
683+
ifFalse: propertyAccess
684+
)
685+
: Expression.Condition(
686+
test: Expression.Equal(instance, Expression.Constant(null, instanceType)),
687+
ifTrue: Expression.Constant(null, p.PropertyType),
688+
ifFalse: propertyAccess
689+
);
684690
}
685691

686692
/// <summary>

0 commit comments

Comments
 (0)