Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my WCF service return and ARRAY instead of a List <T>?

In the web servce I say

 public List<Customer> GetCustomers()
    {
        PR1Entities dc = new PR1Entities();
        var q = (from x in dc.Customers
                select x).ToList();
        return q;
    }

(customer is a entity object)

Then I generate the proxy when I add the service.. and in the reference.cd it say

public wcf1.ServiceReference1.Customer[] GetCustomers() {
        return base.Channel.GetCustomers();
    }

WHY IS IT AN ARRAY? I asked for a List.

help.

like image 285
punkouter Avatar asked Mar 26 '10 17:03

punkouter


Video Answer


1 Answers

Right click on the service reference and select Configure Service Reference.

In the Collection Type drop-down, select the type System.Collections.Generic.List.

I believe the reason it defaults to Array is that it is the most compatible when serializing. If you're consuming the service from something that recognizes something more complex, you can configure as I mentioned.

like image 71
Greg Levenhagen Avatar answered Oct 15 '22 21:10

Greg Levenhagen