😎修复字典验证特性错误

This commit is contained in:
zuohuaijun 2024-12-18 20:47:28 +08:00
parent ff40fcd4ab
commit 3b7570ac39
2 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@
<PackageReference Include="SSH.NET" Version="2024.2.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.5.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1143" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1144" />
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

View File

@ -63,7 +63,7 @@ public class DictAttribute : ValidationAttribute, ITransient
type = type != null ? Nullable.GetUnderlyingType(type) ?? type : null;
// 使用HashSet来提高查找效率
var valueList = (type?.IsEnum ?? DictTypeCode.EndsWith("Enum")) ? dictDataList.Select(u => u.Name) : dictDataList.Select(u => u.Value);
var valueList = (type?.IsEnum ?? DictTypeCode.EndsWith("Enum")) ? dictDataList.Select(u => u.Code) : dictDataList.Select(u => u.Value);
var dictHash = new HashSet<string>(valueList);
if (!dictHash.Contains(valueAsString))