How to validate using annotations in a nested class
问题 I'm trying to manually validate an object using its Data Annotations. Our models have the annotations in a nested class, so that they don't get overwritten when we automatically update them from the database schema. Let's say I have two classes: public class Person { [StringLength(20, MinimumLength = 3, ErrorMessage = "invalid length in Person.LOGIN")] public string Login { get; set; } } [MetadataType(typeof(Car_Metadata))] public class Car { public string Brand { get; set; } public class Car