Wcf Service Basic Part Eleven .

In this lesson we will learn about using [DataContract] and [DataMember] attributes . when we defined a class in wcf service and pass this class or parameters inside interface method,we must use data contract and datamember attributes because when we invoke the wcf service from client application  with valid credential , this credential hit method first then its check all the parameters from client if anything wrong wcf service throw error. Here is the example of using data contract and data member attributes ..

 [DataContract]
  public class CreateAccount
    {
        string account_creation_date;
        string account_type;
        string branch_sort_code;
        string account_fees;
        string account_balance;
        string over_draft_limit;
        string account_holder_id;

        [DataMember]
        public string Account_Creation_Date
        {
            get { return account_creation_date; }
            set { account_creation_date = value; }
        }
        [DataMember]
        public string Account_Type
        {
            get { return account_type; }
            set { account_type = value; }
        }
        [DataMember]
        public string Branch_Sort_Code
        {
            get { return branch_sort_code; }
            set { branch_sort_code = value; }
        }
        [DataMember]
        public string Account_Fee
        {
            get { return account_fees; }
            set { account_fees = value; }

        }
        [DataMember]
        public string Account_Balance
        {
            get { return account_balance; }
            set { account_balance = value; }


        }
        [DataMember]
        public string Over_Draft_Limit
        {

            get { return over_draft_limit; }
            set { over_draft_limit = value; }

        }
        [DataMember]
        public string Account_Holder_Id
        {

            get { return account_holder_id; }
            set { account_holder_id = value; }
        }
    }

No comments:

Post a Comment