Can a WCF service return an instance of an anonymous type or do they need to be a class? My service returns JSON for the website to consume. It would be nice to take a page from MVC and just return something like this and have the service automatically serialize it into JSON.
return new { user = data, lastUpdate = time, success = true };
You can’t ever return an object of an anonymous type from any method. Not and have much useful happen with it.
The problem is not specific to WCF. It just gets worse in WCF since WCF has to worry about generating metadata from your service contract. Remember that the service contract isn’t the part that decides to return JSON, so WCF can’t do anything special for this particular method.