OData Wonderland
Nothing is easy with OData at first.
This ODashit is killing me softly.
At this point I managed to survive in OData wonderland, successfully create working OData function with 3 parameter that return collection of Route entity
http://localhost:20999/CS/odata/Route/f.SearchRoute(DepartureAirportID='KNO',DestinationAirportID='UPG',AirlineID=123)
I Wonder how the hell I expand the navigation property to client ?
Actually it's quite simple, as usual we need to have attribute <HttpGet> and <EnableQuery> then the expand will work
But, remember we are in OData wonderland so odd things happen
    <HttpGet>     <EnableQuery(MaxExpansionDepth:=3)>     Function SearchRoute(departureAirportID As String, destinationAirportID As String, <FromODataUri> airlineID As Integer) As IEnumerable(Of Route)       Dim a = _uowa.RepositoryAsync(Of Route).Query(Function(q) q.RouteItem.DepartureAirport.IATA = departureAirportID And q.RouteItem.DestinationAirport.IATA = destinationAirportID And (q.RouteItem.AirlineID = airlineID Or airlineID = 0)) _             .Include(Function(o) o.RouteItem) _             .Include(Function(r) r.RouteItem.DepartureAirport) _             .Include(Function(s) s.RouteItem.DestinationAirport) _             .Include(Function(p) p.SubRoute) _             .Select() '.AsQueryable()       Return a     End Function
When I add the bold include line, the expand functionality failed withÂ
"Cannot compare elements of type 'System.Collections.Generic.ICollection`1[[CS.Data.Models.Route, CS.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. Only primitive types, enumeration types and entity types are supported."
This is the query that cause the error
http://localhost:20999/CS/odata/Route/f.SearchRoute(DepartureAirportID='KNO',DestinationAirportID='UPG',AirlineID=123)?$expand=RouteItem,SubRoute
And this is the query that solve the error
http://localhost:20999/CS/odata/Route/f.SearchRoute(DepartureAirportID='KNO',DestinationAirportID='UPG',AirlineID=123)?$expand=RouteItem,SubRoute&$top=100
What ? by just adding "&$top=100" what the heck that top statement relate to the error ??!!

















