I’ve created a complex type using the entities framework for the results of a stored procedure I’ve written on a database I’m connected to. I’m now writing a web service to return the results from the stored procedure (i.e. a collection of the complex type I’ve just created). I’ve been specifically asked to return SOAP XML from the WCF service. It was my understanding that a WCF service would ‘automatically’ deal with returning the most appropriate response based on it’s consumers config – so would returning a ObjectResult be succesfully ‘translated’ to XML? Or must I convert to List<> first? And if so – is there a more efficient way than simply looping through the object result?
Thanks a lot, any help seriously appreciated.
EDIT: I must explain that the consumer in this case will be server-side code, I just need to make sure it does return XML should the client be in request of it.
As
ObjectResult<T>implementsIEnumerable<T>, you can useIEnumerableextension methods and get an array of T using:Also make sure
ComplexTypeis serializable.