为什么我的WCF服务回报和数组,而不是一个List< T&GT ;? [英] Why does my WCF service return and ARRAY instead of a List <T>?

查看:121
本文介绍了为什么我的WCF服务回报和数组,而不是一个List< T&GT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网络servce我说

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)

然后我生成代理,当我添加的服务..并在reference.cd它说

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();
    }

为什么一个数组?我问一个List

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

帮助。

推荐答案

右键单击服务引用,并选择配置服务引用。

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

在集合类型下拉列表中,选择类型System.Collections.Generic.List。

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.

这篇关于为什么我的WCF服务回报和数组,而不是一个List&LT; T&GT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆