I am new to using OData with a Web Api. I have my models defined from a database first EF 6 method, and have added the OData controller. The resulting code is erroring out on the following:
< EnableQuery > _
Public Function [Get](<FromODataUri> key As Integer) As SingleResult(Of Product)
Dim result As IQueryable(Of Product) = db.Product.Where(Function(p) p.ID= key)
Return SingleResult.Create(result)
End Function
The error is on the SingleResult providing the following error: SingleResult is ambiguous in system.web.http.
Any advice on what causes this error? Many thanks!
Make sure you don't have multiple OData NuGets installed. I had 2.1 and 2.2 (for OData v4 support) installed, which gave me the exact same issue.
Try this:
Return SingleResult(of Product).Create(result)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With