我不确定这是否是一个问题。
如果我在这里使用 List,它在 root/xml/metadata?op=Competitions 和 root/Competitions 中都有效
[DataContract]
public class CompetitionsResponse : IHasResponseStatus
{
[DataMember]
public List<Competitions> Competitions { get; set; }
//Auto inject and serialize web service exceptions
[DataMember]
public ResponseStatus ResponseStatus { get; set; }
}
HTTP/1.1 200 OK 内容类型:application/xml 内容长度:长度
<CompetitionsResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/FSI.API.ServiceModel">
<Competitions>
<Competitions>
<CompName>String</CompName>
<CompType>String</CompType>
<CompetitionID>0</CompetitionID>
</Competitions>
</Competitions>
<ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:Errors>
<d2p1:ResponseError>
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:FieldName>String</d2p1:FieldName>
<d2p1:Message>String</d2p1:Message>
</d2p1:ResponseError>
</d2p1:Errors>
<d2p1:Message>String</d2p1:Message>
<d2p1:StackTrace>String</d2p1:StackTrace>
</ResponseStatus>
</CompetitionsResponse>
但是如果我使用“IEnumerable”
[DataContract]
public class CompetitionsResponse : IHasResponseStatus
{
[DataMember]
public IEnumerable<Competitions> Competitions { get; set; }
//Auto inject and serialize web service exceptions
[DataMember]
public ResponseStatus ResponseStatus { get; set; }
}
Competitions 集合从元页面 root/xml/metadata?op=Competitions 中消失了
HTTP/1.1 200 OK
内容类型:应用程序/xml 内容长度:长度
<CompetitionsResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/FSI.API.ServiceModel">
<Competitions i:nil="true" />
<ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:Errors>
<d2p1:ResponseError>
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:FieldName>String</d2p1:FieldName>
<d2p1:Message>String</d2p1:Message>
</d2p1:ResponseError>
</d2p1:Errors>
<d2p1:Message>String</d2p1:Message>
<d2p1:StackTrace>String</d2p1:StackTrace>
</ResponseStatus>
</CompetitionsResponse>