Bienvenue dans votre compte. Le2minutes.com. 20minutes.fr, information en continu. Actualités, Politique, Football, People, High Tech. Explorez vos communautés d'intérêts. Ajoutez tout ce que vous aimez où que vous soyez. T411 - Torrent 411 - Tracker Torrent Français - French Torrent Tracker - Tracker Torrent Fr. Panneau de l’utilisateur • Informations. L_Youssef Presentations. TheNewBoston - Free Educational Video Tutorials on Computer Programming, Adobe Software, Computer Science and More! Class-Level Model Validation with EF Code First and ASP.NET MVC 3.
DataAnnotation attributes provides an easy way to validate individual property values on your model classes. Several people have asked - “Does EF Code First also support a way to implement class-level validation methods on model objects, for validation rules than need to span multiple property values?” It does – and one easy way you can enable this is by implementing the IValidatableObject interface on your model classes. IValidatableObject.Validate() Method Below is an example of using the IValidatableObject interface (which is built-into .NET 4 within the System.ComponentModel.DataAnnotations namespace) to implement two custom validation rules on a Product model class. The two rules ensure that: New units can’t be ordered if the Product is in a discontinued state New units can’t be ordered if there are already more than 100 units in stock The IValidatableObject.Validate() method can apply validation rules that span across multiple properties, and can yield back multiple validation errors.
S'inscrire au Support du web. Organisez tous vos intérêts naturellement. Partagez !