Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Unassigned: IQueryable doesn't get serialized properly [1641]

$
0
0
When ODataqueryOptions get binded to the parameters and the query includes a select or an expand, the formatter should be able to serialize IQueryable<IEdmEntityObject>. CanWriteType does the right thing, but ODataSerializerContext.GetEdmType fails to return the right IEdmEntityType. We should check that the type is a SelectExpandWrapper and return the right IEdmType in that case.

public IHttpActionResult Get(ODataQueryOptions<Customer> options)
{
IQueryable<Customer> customers = Enumerable.Range(1, 10).Select(i => new Customer
{
Id = i,
Name = "Name " + i,
Orders = Enumerable.Range(1, i).Select(j => new Order { Id = j }).ToList()
}).AsQueryable();
var query = options.ApplyTo(customers);
IQueryable<IEdmEntityObject> result = query as IQueryable<IEdmEntityObject>;
if (result != null)
{
return Ok(result);
}
else
{
return Ok(query as IQueryable<Customer>);
}
}

Workaround:
IEdmCollectionTypeReference reference = new EdmCollectionTypeReference(Request.GetODataPath().EdmType as IEdmCollectionType);
return Ok(new EdmEntityObjectCollection(reference, result.ToList()));



Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>