locked
changes in metadata are not reflected in client RRS feed

  • Question

  • I have edited a metadata file to indicate required fields and custom error messages on client. it is supposed to generate  validation code on client based on metadata field as per my understanding. but it doesnt. any idea why?

    i am using dataform from april 2010 toolkit

    [Include]
                public Admin Admin { getset; }
     
                public int AdminID { getset; }
     
                [Required(ErrorMessage="Contact No is required.")]
                public string ContactNo { getset; }
     
                [Exclude]
                public int CreatedBy { getset; }
     
                [Exclude]
                public DateTime CreatedDate { getset; }
     
                public EntityCollection<Domain> Domains { getset; }
     
                [Required(ErrorMessage="Email is required.")]
                [RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Invalid E-Mail ID")]
                public string Email { getset; }
     
                public int ID { getset; }
     
                public EntityCollection<Invoice> Invoices { getset; }
     
                [Exclude]
                public Nullable<int> LastUpdatedBy { getset; }
     
                [Exclude]
                public Nullable<DateTime> LastUpdatedDate { getset; }
     
                //[Required(ErrorMessage="Name is reduired.")]
                public string Name { getset; }
     
                public EntityCollection<Project> Projects { getset; }
     
                [Exclude]
                public bool Status { getset; }
    the metadata changes related to name field are not reflcted in client side validation?
    could it be because of the name of the field or the word "name" being the keyword.
    am a newbie so look accordinglly.
    the field Name is a required field in the database table. could that be the reason? if so, anyway one can override it in metadata?
    thanks.
    Sunday, March 18, 2012 9:20 AM

Answers

  • FIrst thing to try is in the EDMX file go to the properties of the entity and change  that field to not be required. I am not 100% if that will work or not, I haven't used the EDMX in quite awhile I I haven't had time to try it yet.

    Otherwise, you can create your own NotRequired attribute. Have it inherit from Required and then in the IsValid return success. The existance of a user supplied attribute that inherits from required will prevent required itself from getting generated.

    Wednesday, March 21, 2012 5:18 PM

All replies

  • If you are using Entity Framework, if the database has a field marked as nullable=false and your EDMX has the same then the Required attribute is generated automatically. If you modify the edmx to say that name is not required then it should become not required on the client.

    Tuesday, March 20, 2012 10:20 AM
  • @ColinBlair: precisely. but how to mark it as not required when its nullable=false in the database. it should override the default provided by DB. but as opposed to [Required] attribute, i cant find any [NotRequired] attribute. 

    i am sure its pretty simple and i am gonna be ashamed once i get it. but i tried searching and didnt get anything, so needed to ask. how do i mark it as not required when it defaults to required due to database.

    thanks

    Wednesday, March 21, 2012 3:30 AM
  • FIrst thing to try is in the EDMX file go to the properties of the entity and change  that field to not be required. I am not 100% if that will work or not, I haven't used the EDMX in quite awhile I I haven't had time to try it yet.

    Otherwise, you can create your own NotRequired attribute. Have it inherit from Required and then in the IsValid return success. The existance of a user supplied attribute that inherits from required will prevent required itself from getting generated.

    Wednesday, March 21, 2012 5:18 PM
  • the edmx thing doesnt work.

    not sure if the custom attribute works. for now, i have gone a different anyway but thanks for the replies.

    turns out i had a different approac possible for it.

    Thursday, March 22, 2012 11:11 AM