在WCF数据服务ServiceOperation中返回自定义对象

时间:2013-04-16 15:51:00

标签: wcf-data-services odata

是否可以在WCF数据服务ServiceOperation中返回自定义对象或通用对象,如:

public class Message {
    public string value { get; set; }
}

[WebGet]
public Message test() {
    return new Message { value = "HelloWorld!" };
}

[WebGet]
public object test2() {
    return new { message = "HelloWorld!" }
}

谢谢。

1 个答案:

答案 0 :(得分:0)

我知道这是一个较旧的问题,但我会发布此链接,指明服务操作的要求:

Service Operations (WCF Data Services)

此外,您可以从服务操作中查看返回的复杂类型。