Visual Studio 2012 Odata Endpoint Issue - kendo-ui

I'm builing an Odata end point with WebApi 2 and Visual Studio 2012, using the ODataController. The end point works but the data is clearly v4 format while the DataServiceVersion is 3.0. In fact, it looks a lot like the output of this Microsoft post. This post seems to have the same issue, it clearly uses [odata.] and [value] instead of __count and results. My front end is a Telerik datasource and it doesn't know what to do with the mismatch. What can be done to resolve this?
http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint

OData WebbAPI V3 supports Json Light and Json Verbose both. Accept:application/json would returns Json light, which make it look same as V4, but in fact it is still v3. Seems you would like return json verbose, then you can set the header to Accept:application/json;odata=verbose.
You can check the bottom of the post. http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint

Related

Odata v4 orderby expand webapi

so I am using webapi with the latest version of odata
I am trying to sort and filter my expand,
http://services.odata.org/V4/Northwind/Northwind.svc/Orders?%24select=OrderID&%24expand=Order_Details(%24select=UnitPrice;%24orderby=UnitPrice%20desc)
not getting any errors as the data comes back with no issue, however the the orderby inside of the expand dose nothing.
is this sort allowed?
if not do you know of a workaround?
thanks
This is not supported yet, see this issue to track the progress. https://github.com/OData/WebApi/issues/557

OData V4 - Expand and options (filter, top, ...)

I'm using OData V4 with ASP WebApi. I would filter an expanded collection as the new version of OData can do (http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html - Example 90) but in my case the filter option has no effect.
I also tried to do the same thing with the Nortwhind service and the TripPin service. It works for the TriPin service, but not for Northwind service.
Here, the requests that I used :
My Service : api/odata/Customers(19037)?$expand=orders($filter=id+eq+1796) --> Doesn't work
Northwind Service : http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$expand=Orders($filter=OrderID+eq+10643) --> Doesn't work
TripPin Service : http://services.odata.org/V4/TripPinServiceRW/People?$expand=Trips($filter=TripId+eq+1001) --> Does Work
Thanks for your help.
This is a feature we don't support for now.
The root cause is that the inline $filter is ignored while translating $expand.
Check method "GetPropertiesToExpandInQuery" of SelectExpandBinder.cs:
https://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.OData/OData/Query/Expressions/SelectExpandBinder.cs
Only expandItem.SelectAndExpand is returned while other options are ignored.
So only $select and $expand inside $expand work for now.
I have investigated how to fix it before, but since the issue is not approved,
please vote the issue Jinfu opened to draw more attention of lead team.
I reproduced the issue, and found $select inside a $expand works well. I believe this is a defect and opened a bug for it: https://aspnetwebstack.codeplex.com/workitem/2070.

checking validity for standard SOAP web service

Is this a valid web service link since I tried ti import it several times to visual studio 2010 and 2012 and couldnt read it from code behind.
http://www.hotelston.com/ws/HotelService?wsdl
whats the service name I should call ?
Yes this is a valid WSDL and it is a WSI compliant WSDL as well. I ran the tests with SOAP UI and it appears to be fine. The service name is HotelService it has three ports one for SOAP 1.1 another for SOAP 1.2 and finally one for HTTP. It is document literal wrapped so cant see anything problematic.
I also imported the WSDL into a XML editor and had a look. It appears fine see image below.

jaydata/jaysvcutil 1.3.5 inverseProperty support for WebAPI

I've seen Missing inverse property in asp.net webapi odata $metadata and the WebAPI $metadata I'm dealing with behaves as described in this article: it doesn't reuse associations for bi-directional navigation properties.
When using jaysvcutil 1.3.5 all navigational properties come up as $$unbound.
$data.Entity.extend('API.Models.Document', {
...
'Document_Versions': {
'type':'Array',
'elementType':'API.Models.Document_Versions',
'inverseProperty':'$$unbound' }
});
Other than manually updating the inverseProperty information is there anything to get the desired result automatically?
Update based on #Robesz answer
Manually adding inverseProperty information to the static .js converted by JaySvcUtil is doable, but I'm asking if there's an option to accomplish that with the dynamic conversion as well.
There seems to be to options
make modifications to the .NET WebAPI. Might be challenging, because their seem to be good reason for their implementation, but maybe somebody already successfully did that.
modifying the conversion XSLT that JayData using to take that behavior into account.
We've just arrived to the same results with WebAPI OData, but after editing the generated context file manually and adding the inverseProperty everything is working fine
This should be most probably handled by extending JayData's XSLT conversion. I've created an issues for that on https://github.com/jaydata/jaydata/issues/155.

Web Api and Odata without Entity Framework

I am having trouble getting OData to work with Asp.Net Web Api when the underlying data is NOT coming from Entity Framework.
I am using the latest OData Nuget package (Microsoft ASP.NET Web API OData 0.2.0-alpha release) but when I attempt to pass an OData query (say $top=10) I receive the error:
The given key was not present in the dictionary
If I don't send an OData query I can call the method just fine. The other methods in the same Web Api project that use Entity Framework work fine with OData queries. The one's that don't work are using Subsonic ORM to query an underlying AS400 data source. It returns an IQueryable. This worked just fine before the VS 2012 and .NET 4.5 RTM was released and OData was moved into a separate package. (i.e. worked with beta and RC versions of VS2012 and .NET 4.5)
Any ideas would be appreciated.
I guess this issue is caused by stable ordering, which doesn't work well with the underlying query provider. Could you put the call stack of the error to confirm it?
One big change with OData query composition in this release is that it ensures stable ordering before taking top items. The reason to do that is user may have random data source which makes return data keep changing.
The way web api odata package does is to add OrderyBy [Keys] query before executing top. Or if there is no key defined in the model (Keys are ID, EntityID, or [Key] attributed property), it will use all the primitive properties in the model to order.
If you can make sure that the data source will always return data with stable ordering, you can turn off this feature by code:
[Queryable(EnsureStableOrdering = false)]

Resources