mirror of
https://github.com/dotnetcore/BootstrapBlazor.git
synced 2025-12-20 10:26:41 +08:00
!1944 feat(#I4D8DL): model support MedadataTypeAttribute on TableColumn component
* chore: bump version to 5.14.5 * feat: 读取模型标签支持 MedadataType 方式
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>5.14.4</Version>
|
||||
<Version>5.14.5</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
||||
@@ -148,8 +148,12 @@ namespace BootstrapBlazor.Components
|
||||
var cacheKey = (ModelType: modelType, FieldName: fieldName);
|
||||
if (!PropertyInfoCache.TryGetValue(cacheKey, out propertyInfo))
|
||||
{
|
||||
// 支持 MetadataType
|
||||
var metadataType = modelType.GetCustomAttribute<MetadataTypeAttribute>(false);
|
||||
|
||||
// Validator.TryValidateProperty 只能对 Public 属性生效
|
||||
propertyInfo = cacheKey.ModelType.GetProperties().Where(x => x.Name == cacheKey.FieldName).FirstOrDefault();
|
||||
propertyInfo = metadataType?.MetadataClassType.GetProperties().Where(x => x.Name == cacheKey.FieldName).FirstOrDefault()
|
||||
?? cacheKey.ModelType.GetProperties().Where(x => x.Name == cacheKey.FieldName).FirstOrDefault();
|
||||
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user