none
Change a key of List being exposed RRS feed

  • Question

  • HI

    i am writing a WCFservice where it exposes as list to front end.It will be like

    Public List<customers> get Customers()

    {

    //code goes here like DB operations

    }

    Here customer List Contains following files

    int Id{set;get;}

    int CustomerName{set;get;}

    int CustomerPlace{set;get;}

    here in this list i want Id to displayed as CustomerId.I cannot Chnage the name of field as i am using some autommaper for databse.So is there any thing which can Change Id to Customer Id while exposing from WCF Service

    Please Help me to solve this.

    Thanks in advance


    Friday, November 11, 2016 7:48 AM

All replies

  • Hi Jayadeep,

    What do you mean by changing Id to Customer Id while exposing from WCF Service? Do you mean get CustomerId in wsdl or WCF response?

    I suggest you try to add DataContract and DataMember for Customer Class.

    Here is a simple code:

        [DataContract]
        public class customers
        {
            [DataMember(Name="CustomerId")]
            int Id { set; get; }
            [DataMember]
            int CustomerName { set; get; }
            [DataMember]
            int CustomerPlace { set; get; }
        }

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Saturday, November 12, 2016 10:10 AM