在网络服务中我说
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/