OData questions continue :)
I have an Entity with a compound key, like this one:
public class Entity { public virtual Int32 FirstId { get; set; } public virtual Guid SecondId { get; set; } public virtual First First { get; set; } public virtual Second Second { get; set; } }
I created a CompositeKeyRoutingConvention that handles compound keys for ODataController s. Everything works, except for navigation links, such as:
http://localhost:51590/odata/Entities(FirstId=1,SecondId=guid'...')/First
The following error message appears in Firefox:
<?xml version="1.0" encoding="utf-8"?> <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <m:code /> <m:message xml:lang="en-US">No HTTP resource was found that matches the request URI 'http://localhost:51950/odata/Entities(FirstId=1,SecondId=guid'a344b92f-55dc-45aa-b92f-271d74643493')/First'.</m:message> <m:innererror> <m:message>No action was found on the controller 'Entities' that matches the request.</m:message> <m:type></m:type> <m:stacktrace></m:stacktrace> </m:innererror> </m:error>
I traced the error message in the ASP.NET source code to the FindMatchingActions method in ApiControllerActionSelector , returning an empty list, but my ASP.NET knowledge ends there.
For reference, this is an implementation of the navigation link action method (in ODataController ):
public First GetFirst( [FromODataUri(Name = "FirstId")] Int32 firstId, [FromODataUri(Name = "SecondId")] Guid secondId) { var entity = repo.Find(firstId, secondId); if (entity == null) throw new HttpResponseException(HttpStatusCode.NotFound); return entity.First; }
I tried not to set the name in the FromODataUri attribute by setting a lowercase name, all reasonable that I could think of. The only thing I noticed is that using the regular EntitySetController is that the arguments for the key value must be named key (or the FromODataUri attribute must have the Name property set to key ), otherwise it wonโt work. I wonder if something like this is here ...