Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Issue: Provide action names with navigation property in LinkRoutingConvention [656]

$
0
0
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;
break;

default:
throw ODataErrors.CreatingLinkNotSupported(Request, navigationProperty);
}
_db.SaveChanges();

return Request.CreateResponse(HttpStatusCode.NoContent);
}

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>