Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace the classes of System.ComponentModel.DataAnnotations for .NET Standard?

.NET Standard did not support 'System.ComponentModel.DataAnnotations', and 'System.Type.Properties', how to keep compatible with it ?

like image 281
coffeedrunk Avatar asked Apr 20 '17 01:04

coffeedrunk


People also ask

What is system component model DataAnnotations?

System.ComponentModel.DataAnnotations Namespace. The System.ComponentModel.DataAnnotations namespace provides attribute classes that are used to define metadata for ASP.NET MVC and ASP.NET data controls. Extends the metadata information for a class by adding attributes and property information that is defined in an associated class.

What is system componentmodel in ASP NET?

The System.ComponentModel.DataAnnotations namespace provides attribute classes that are used to define metadata for ASP.NET MVC and ASP.NET data controls. Extends the metadata information for a class by adding attributes and property information that is defined in an associated class.

What is componentmodel in Entity Framework?

The namespace System.ComponentModel.DataAnnotations, has a group of classes, attributes and methods, to make validations in our.NET applications. In the Microsoft world, there are technologies such as WPF, Silverlight, ASP MVC, Entity Framework, etc., which make automatic validation with class and exclusive attributes.

How to implement data anotation in Java?

Step 1: Data Anotation is in the namespace System.ComponentModel.DataAnnotations, so this must be added as a reference to your application. Step 2: Create an Interface, all model class on which we want to perform Validation, all the classes inherit from this interface. .... .... ....


1 Answers

The types from the System.ComponentModel.DataAnnotations namespace are in the System.ComponentModel.Annotations package, which is not installed by default in a .Net Standard library, so you need to install it manually to use it there.

If you mean Type.GetProperties(), then that method exists as an extension method in .Net Core and in .Net Standard. In a .Net Standard library, you will need to install the System.Reflection.TypeExtensions package. In both a .Net Core application and a .Net Standard library, you will need to add using System.Reflection; to your source.

like image 134
svick Avatar answered Oct 21 '22 00:10

svick