This project is read-only.


Provide action names with navigation property in LinkRoutingConvention


Instead of "CreateLink" or "DeleteLink" names for actions that this convention currently generates, could we have actions like "CreateLinkTo<NavigationProperty>" below out of the box?

Example: CreateLinkToFamily, CreateLinkToProducts

otherwise currently users would have to use conditional statement like below:

public HttpResponseMessage CreateLink(int key, string navigationProperty, [FromBody] Uri link)
        Product product = _db.Products.SingleOrDefault(p => p.ID == key);

        int relatedKey = ODataHelper.GetKeyValue<int>(Request.GetConfiguration(), link);

        switch (navigationProperty)
            case "Family":
                // The utility method uses routing (ODataRoutes.GetById should match) to get the value of {id} parameter 
                // which is the id of the ProductFamily.
                ProductFamily family = _db.ProductFamilies.SingleOrDefault(f => f.ID == relatedKey);
                product.Family = family;

                throw ODataErrors.CreatingLinkNotSupported(Request, navigationProperty);

        return Request.CreateResponse(HttpStatusCode.NoContent);
Closed Oct 11, 2013 at 4:45 PM by jacalvar


HongmeiG wrote Dec 10, 2012 at 11:52 PM

Nice to have for RTM.