visual basic

Topics: ASP.NET Web API
Feb 5, 2013 at 7:17 PM
I have a vb sample which doesnt work, same as c# works

Public Class OrdersController
Inherits ODataController

Dim nw As NorthwindEntities = New NorthwindEntities
' GET api/<controller>
Public Function GetValue() As IQueryable(Of Orders)
    Return nw.Orders.AsQueryable
End Function
Feb 5, 2013 at 9:45 PM
Could you please elaborate on how exactly it isn't working?
Feb 6, 2013 at 3:16 PM
Correct me if I'm wrong, but I don't think a function name of "GetValue" matches any of the possible default conventions for an ODataController. Shouldn't it just be "Get"?
Feb 6, 2013 at 3:27 PM
Richard's absolutely right. The action conventions are a bit different for OData. If you derive from ODataController, you should make sure to have an OData route configured, and you should make sure that the Get entity set method either has the name "Get{EntitySetName}" or just "Get". So if your entity set name was Orders here, you could either call it "GetOrders" or "Get".
Feb 6, 2013 at 6:58 PM
Edited Feb 6, 2013 at 7:01 PM
Get is a reserved keyword in VB.
GetOrders works in fact. Conventions should sometimes be documented
Feb 6, 2013 at 7:10 PM
Edited Feb 6, 2013 at 7:11 PM
Don't worry, it will be. The final bits haven't even been released yet, give us a little time : )

I'll be writing a blog post about routing conventions in the coming weeks and I expect we'll have official documentation up at some point as well.