Metadata Generator template with Self validation

Jul 31, 2012 at 5:13 PM

Hi, 

Nice template thank you. I was wondering if there's a way to include selfvalidation within the classes it generates? like the underlined?

something like below? Obviously writing manually would be painful correct? 

[MetadataType(typeof(ApplicationUserCredentialMetadata))]
	public partial class ApplicationUserCredential
	{
		internal sealed class ApplicationUserCredentialMetadata
		{

            [SelfValidation]
            public static void SelfValidator(ApplicationUserCredential instance, ValidationResults results)
            {
                // TODO: Your validation here.
            }

			[Required(ErrorMessage="Application User Credential is required")]
    		public Int32 ApplicationUserCredentialID { get; set; }

			[Required(ErrorMessage="Application User is required")]
    		public Int32 ApplicationUserID { get; set; }

			[Required(ErrorMessage="User Login Domain is required")]
			[StringLength(255)]
    		public String UserLoginDomain { get; set; }

			[Required(ErrorMessage="User Login Name is required")]
			[StringLength(255)]
    		public String UserLoginName { get; set; }

			[Required(ErrorMessage="Last Update User is required")]
			[StringLength(255)]
    		public String LastUpdateUser { get; set; }

			[DataType(DataType.DateTime)]
    		public DateTime LastUpdateDateTime { get; set; }

    		public EntityCollection ApplicationUser { get; set; }

		}
	}

Can you please help?

I'm trying to have self validation like this link

http://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=80

Kavya