Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF and Anonymous Types

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

like image 496
Tamim Sadikali Avatar asked Oct 14 '09 15:10

Tamim Sadikali


2 Answers

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

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).

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.

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.

Marc

like image 151
marc_s Avatar answered Oct 01 '22 08:10

marc_s


You can't return an anonymous type from any method, can you? So why would you be able to return it from WCF?

like image 20
John Saunders Avatar answered Oct 01 '22 09:10

John Saunders