locked
Data annotations RRS feed

  • Question

  • User269846090 posted

    I am a beginner for data annotations. Have a doubt on the following code snipet.

    [Required]      -- is a default one

    [StringLength(15)]  -- is a default one

    [Country(AllowCountry="USA")] ----- It is not default attribute.. then what is this..? If it is custome attribute then how we need to create custom attribute?

    pls help..

    public class Customer
    {
    	[Required]
    	public virtual string CustomerID { get; set; }
    
    	[Required]
    	[StringLength(15)]
    	public virtual string CompanyName { get; set; }
    
    	public virtual string Address { get; set; }
    
    	public virtual string City { get; set; }
    
    	public virtual string PostalCode { get; set; }
    
    	[Country(AllowCountry="USA")]
    	public virtual string Country { get; set; }
    
    	[Phone]
    	public virtual string Phone { get; set; }
    }
    Wednesday, May 13, 2015 7:55 AM

Answers

All replies