I have succesfully implemented a RESTful Web Service using the .NET 4.0 framework with MVC 4 and the ApiController
class.
I have a method, let's say GetMovies
("/api/movies") that returns an IQueryable<Movie>
. Serialization is done using DataContractSerializer
, of course. The problem is in the name of the returned list, because it is ArrayOfMovie
:
<ArrayOfMovie>
<Movie></Movie>
<Movie></Movie>
...
<Movie></Movie>
</ArrayOfMovie>
I cannot create a custom class, let's say Movies
, and add a [CollectionDataContract(Name = "movies")]
annotation (as suggested at https://stackoverflow.com/a/4593167/801065) because I cannot extend IQueryable
without implementing all of its methods. And I most definitely need an IQueryable for OData/jQuery processing.
How can I solve this? Is there an annotation that can help me?