WCF和匿名类型 [英] WCF and Anonymous Types

查看:64
本文介绍了WCF和匿名类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过WCF返回匿名类型.这可能吗?

I want to return an anonymous type over WCF. Is this possible?

推荐答案

您不能使用匿名类型,但是也许您在谈论WCF和无类型消息?

You cannot use anonymous types, but maybe you are talking about WCF and untyped messages?

在WCF中有一个选项可以仅定义类型为Message的参数(可能还定义相同类型的返回值).这只是传递给WCF的原始消息(并从中返回).

There is an option in WCF to just define a parameter of type Message (and possibly a return value of the same type). This is just the raw message that goes to WCF (and comes back from it).

我在那里找不到很多好的信息-MSDN上有一些文档,但是到目前为止,我所看到的最好的是Kurt Claeys的博客文章

I can't find much good information out there - there's some documentation on MSDN, but the best I've seen so far is Kurt Claeys' blog post WCF : Untyped messages on WCF operations.

我不建议您使用这种方法-亲自直接处理消息内容要花很多精力,这就是WCF试图避免的事情-但是,如果您绝对要积极地调整消息的每一点-这似乎是要走的路.

I would not recommend using this approach - it's a lot more grunt work to handle the message contents directly yourself and that's what WCF is trying to spare us from - but if you absolutely, positively have to tweak every bit of your message - this seems like the way to go.

马克

这篇关于WCF和匿名类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆