我有一个 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/