.net-core - 如何替换 .NET Standard 的 System.ComponentModel.DataAnnotations 类?

标签 .net-core .net-standard

.NET Standard 不支持“System.ComponentModel.DataAnnotations”和“System.Type.Properties”,如何保持兼容?

最佳答案

来自 System.ComponentModel.DataAnnotations 的类型命名空间位于 the System.ComponentModel.Annotations package ,默认情况下不会安装在 .Net Standard 库中,因此您需要手动安装它才能在那里使用它。

如果您的意思是 Type.GetProperties() ,那么该方法作为 .Net Core 和 .Net Standard 中的扩展方法存在。在 .Net Standard 库中,您需要安装 the System.Reflection.TypeExtensions package .在 .Net Core 应用程序和 .Net Standard 库中,您都需要添加 using System.Reflection;到您的来源。

关于.net-core - 如何替换 .NET Standard 的 System.ComponentModel.DataAnnotations 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43508648/

相关文章:

c# - 如何使内部结构对 .NET Standard 中的多个其他程序集可见

c# - 在适用于 .NET 的 Azure 管理库中创建具有多个声明的 Azure 服务总线策略

c# - 如何在 EF Core 中使用 LINQ 将原始数据类型列表与实体连接起来?

c# - 如何将 DLL 从 .Net Framework 迁移到 .Net Standard?

c# - 仅从 API 返回对象属性的子集

c# - 如何在 Roslyn 动态编译代码中引用另一个 DLL

c# - Entity Framework 核心 : many-to-many relationship with same entity

visual-studio - 在 .Net Core 中创建自定义 Sdk

c# - 在 C# 中导入和导出 RSA key

azure - WindowsAzure.Storage SDK 缺少 .NET Standard 中的 API