Ask a questionAsk a question
 

AnswerCreate Annotation for XSD

  • Wednesday, August 02, 2006 12:33 PMWebbert Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have a relatively complex schema that was converted into a DataContract.  In doing so, I lost the ability to do somethings like constraints, which I will have to do in Business logic.  I would like to convey the constraints to the end consumer through the use of annotation. 

    Is there any way to annotate the XSD that is being generated?  I would like to do something like the following and have it show in the schema.

    Thanks,
    Dave

     

    [DataContract]
    public class Person
    {
        private string _firstName;
        private string _lastName;
     
        public Person() { }
        public Person( string first, string last )
        {
            this._firstName = first;
            this._lastName = last;
        }
     
        [DataMember(Annotation="This is the first name of the person.")]
        public string FirstName
        {
            get { return ( _firstName ); }
            set { _firstName = value; }
        }
     
        [DataMember(Annotation="This is the last name of the person.")]
        public string LastName
        {
            get { return ( _lastName ); }
            set { _lastName = value; }
        }
    }
     
     

Answers

All Replies