Reputation: 19396
In my WCF service contract I have declared an asyn method that return a List, but when in my client I receive the return from the method, I receive an array. My contract is the following:
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginGetUsers(Paramusers paramUserParameters, AsyncCallback callback, object state);
List<Users> EndGetUsers(IAsyncResult result);
In my client I have the following code:
Task<List<Users>> task = Task<List<Users>>.Factory.FromAsync(_proxy.Proxy.BeginGetUsers, _proxy.Proxy.EndGetUsers, myParameters, null);
List<Users> myUsers = await task;
In the client, I receive an error in the second parameter of FromAsync method, because it says that the EndGetUsers method returns an array, not a list.
I try to use an array of users and works fine, but I would like to receive the list from the async method, not an array. is it possible?
Thanks. Daimroc.
Upvotes: 0
Views: 745
Reputation: 87308
When you create your client proxy, specify that you want collections to be represented as lists instead of arrays - when using the "Add Service Reference" dialog, choose the "Advanced" button, then select System.Collections.Generic.List
in the collection type drop-down list.
If you use svcutil
, you can use the /collectionType
(or /ct
) parameter to specify the type of collections to use:
svcutil http://the.service.com/service.svc /ct:System.Collections.Generic.List`1
Upvotes: 7