WCF service method Implementation to Repository with multiple parameters

Answered WCF service method Implementation to Repository with multiple parameters

  • 23 April 2012 20:37
     
     

    I'm trying to Setup WCF Service to create an entry in database table and return the same along with bunch of related data as Response of service.

    I'm using EF with Repository Pattern to do all DataAccess work. Since the passing parameters are quiet huge list(15+).

    Complex type (DTO) is much cleaner way of doing this?. or any other alternative for this.

    I'm looking for cleaner and simple implementation...

Semua Balasan

  • 24 April 2012 8:57
    Moderator
     
     Jawab Memiliki Kode

    If you want to pass multiple parameters to the WCF service method, then you could create a data contract class which contains these parameters, and then specify this contract type as its parameter for your WCF operation. for example:

    [DataContract]
     public class MyContract
     {
        [DataMember(Order=1)]
        public string Parameter1 { get(); set{};}
        [DataMember(order=2)]
        public string Parameter2 { get(); set{};}
      }


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework