I have a Web Api using Odata v3, and some entities are composite, like this one:
public class AerodromoAdministracaoData { [Key] [Column("idAerodromo", Order = 0)] [DatabaseGenerated(DatabaseGeneratedOption.None)] public short IdAerodromo { get; set; } [Key] [Column("data", Order = 1, TypeName = "date")] public DateTime Data { get; set; } public virtual Aerodromo Aerodromo { get; set; } }
I followed this msdn article and created the NavigationRoutingConvention site . Now the application processes compound keys. However, navigation links like this do not work:
http://localhost/WebApiV3/AerodromoAdministracaoData%28idAerodromo=1,data=%272014-10-24%27%29/Aerodromo
I keep getting "An HTTP resource not found that matches the request", as if this method were not implemented in the controller. By the way, this is the controller method:
[EnableQuery] public Aerodromo GetAerodromo([FromODataUri] short idAerodromo, [FromODataUri] DateTime data) { AerodromoAdministracaoData result = Store.AerodromoAdministracaoData.Find(idAerodromo, data); if (result == null) { throw new HttpResponseException(new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.NotFound)); } return result.Aerodromo; }
I found this question talking about exactly the same problem, but I did not understand how Nikon fixed the problem.
source share