简体   繁体   中英

Web API + PowerPivot with dynamic entities

Since ASP.Net 2012.2 was released I have been attempting to create a Web API which returns OData which in turn can be consumed by PowerPivot. I have this working with a predefined model.

However I have a scenario whereby I will not know the number of properties prior to the request being made. What I would like to do is be able to execute a stored procedure to get a DataTable and be able to return the contents of this DataTable as odata.

My initial attempts with returning an IQueryable<DataRow> ended up with the following response.

Response, Status=406 (NotAcceptable), Method=GET, Url=http://localhost:43438/odata/Products, Message='Content-type='none', content-length=unknown'

I have since attempted to use ExpandoObject to create a dynamic object to represent the contents of the DataTable however this also gives the response above.

Is there a feasible way to use a dynamic number of properties and serialize this to OData?

You should build an EDM model and add an OData route. Refer to this blog post for the 3 steps to do to expose odata services.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM