asp.net - 为什么我的 WCF 服务返回和 ARRAY 而不是 List <T>?

标签 asp.net wcf generics

在网络服务中我说

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

(客户是实体对象)

然后我在添加服务时生成代理..并在reference.cd中说
public wcf1.ServiceReference1.Customer[] GetCustomers() {
        return base.Channel.GetCustomers();
    }

为什么是数组?我要了一份 list 。

帮助。

最佳答案

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

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

我相信它默认为 Array 的原因是它在序列化时最兼容。如果您从识别更复杂事物的事物中使用该服务,您可以按照我提到的方式进行配置。

关于asp.net - 为什么我的 WCF 服务返回和 ARRAY 而不是 List <T>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2525463/

相关文章:

c# - 仅由一个用户使用的虚拟目录上的 ServerTooBusyException

.net - EndpointNotFoundException 的可能原因是什么?

java - 为什么类型变量在java中是不可具体化的类型

performance - 如何让我的 Rust 函数更通用和高效?

asp.net - css 停止工作 asp.net

c# - Iframe 中的回发导致 Safari 浏览器中的 Viewstate MAC 错误

jquery - 选择 : jQuery plugin. ..在 asp.net 回发后不起作用

c# - 新窗口打开gridview,页面间传递参数

wcf - Silverlight 应用程序能否从一个调用接收多个回调?

c# - 基本泛型接口(interface)上的扩展方法