要移除的服务栈arrayof [英] Service stack arrayof to be removed
本文介绍了要移除的服务栈arrayof的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 dto 定义为
[DataContract(Name = "Tuner", Namespace = "")]
public class TunerDto
{
[DataMember(Name = "TunerName", Order = 1)]
public string TunerName { get; set; }
}
并且我返回了一组论文,它在正文中给出了我的 XML:
and I am returning an array of theses which gives my XML in the body as:
<ArrayOfTuner>
<Tuner>
<Name>Test1</Name>
</Tuner>
...
</ArrayOfTuner>
有没有办法用 Tuners 代替 ArrayOfTuner?
Is there a way of replacing ArrayOfTuner with Tuners instead?
推荐答案
你应该把你的数组包装在一个类中,这样你就可以添加一个 [CollectionDataContract]
属性来修改序列化输出:>
You should wrap your array in a class, so you can add a [CollectionDataContract]
attribute to modify the serialization output:
[CollectionDataContract(ItemName = "Tuner")]
public class Tuners : List<TunerDto>
{
public Tuners() { }
public Tuners(IEnumerable<TunerDto> collection) : base(collection) { }
}
这篇关于要移除的服务栈arrayof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文