c# - 在 c# 中生成的代理类中列出 vs 数组

标签 c# wcf

我有一个 WCF 服务,当我使用 svcutil 生成客户端代理类时,它将我的列表属性更改为数组。是否有一个选项可以确保我在不修改 C# 中生成的类的情况下维护列表?

//The object in the service…

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.2152")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://brax.com/data/Query")]
public partial class PayloadType
{
    private List<PersonType> personBasedQueryField;
    private List<LocationType> locationBasedQueryField;


//Generated class...

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.2152")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://brax.com/data/Query")]
public partial class PayloadType
{
    private PersonType[] personBasedQueryField;
    private LocationType[] locationBasedQueryField;

最佳答案

是的,在 Visual Studio 的服务引用中有选项。您可以选择将集合生成为列表。

更新:如果您正在使用 svcutil.exe ,您可以使用此选项:

/collectionType:<type>

关于c# - 在 c# 中生成的代理类中列出 vs 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8445502/

相关文章:

c# - 绑定(bind)上的 StringFormat

c# - 查找两个嵌套字典之间的差异

.net - WCF - 已超过传入消息的最大消息大小配额

c# - WCF未处理的用户代码异常

wcf - 在 IIS7 上部署 WCF 教程应用程序 : "The type could not be found"

c# - ASP.NET中长轮询结合WCF服务监控的例子?

c# - C# 允许双分号吗? ;如果是这样,有什么特殊的方法吗?

c# - 通过 Skype 通话发送音频

c# - 算法:基于相同序列的数字替换

wcf - 导致 ServiceActivationException 的原因是什么?