1

I want to return response that contains the item array.
I want to able to use any class with this response. So the item array is a generic IList property.

My client app reuses the Response and Dto class library. When try to update service reference is fail; no proxy class generated. I searched and figure out that I need to fix this generic list using way.

How can I achive this?

Response class:

namespace x.Response
{
     [DataContract]
     public class BlockDataResponse<T> : ResponseBase
     {
            [DataMember]
            public IList<BlockDataDto<T>> DataList { get; set; }
     }
}

Item class that in response class:

namespace x.Dto
{
    [DataContract]
    public class BlockDataDto<T>
    {
        [DataMember]
        public int RecordIndex { get; set; }

        [DataMember]
        public T Data { get; set; }
    }
}

Any type of class:

   namespace x.Dto.Definitions
   {    
       [DataContract]
       public class AbcDto : DtoBase<AbcDto>
       {
           [DataMember]
           public string Property1 {get; set;}
           //...
       }
   }

Service method:

  [OperationContract]
  BlockDataResponse<AbcDto> GetAbcData(int startIndex, int blockSize);
Uğur Aldanmaz
  • 1,018
  • 1
  • 11
  • 16

1 Answers1

0

Ok. I just solved my problem.

Response class:

namespace x.Response
{
     [DataContract]
     public class BlockDataResponse<T> : ResponseBase
     {
            [DataMember]
            public IList<T> DataList { get; set; }
     }
}

Item class that in response class:

namespace x.Dto
{
    [DataContract]
    public class BlockDataDto<T>
    {
        [DataMember]
        public int RecordIndex { get; set; }

        [DataMember]
        public T Data { get; set; }
    }
}

Any type of class:

   namespace x.Dto.Definitions
   {    
       [DataContract]
       public class AbcDto : DtoBase<AbcDto>
       {
           [DataMember]
           public string Property1 {get; set;}
           //...
       }
   }

Service method:

  [OperationContract]
  BlockDataResponse<BlockDataDto<AbcDto>> GetAbcData(int startIndex, int blockSize);
Uğur Aldanmaz
  • 1,018
  • 1
  • 11
  • 16