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

Edited 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?<br /><br />Example: CreateLinkToFamily, CreateLinkToProducts<br /><br />otherwise currently users would have to use conditional statement like below:<br /><br />public HttpResponseMessage CreateLink(int key, string navigationProperty, [FromBody] Uri link)<br /> {<br /> Product product = _db.Products.SingleOrDefault(p => p.ID == key);<br /><br /> int relatedKey = ODataHelper.GetKeyValue<int>(Request.GetConfiguration(), link);<br /><br /> switch (navigationProperty)<br /> {<br /> case "Family":<br /> // The utility method uses routing (ODataRoutes.GetById should match) to get the value of {id} parameter <br /> // which is the id of the ProductFamily.<br /> ProductFamily family = _db.ProductFamilies.SingleOrDefault(f => f.ID == relatedKey);<br /> product.Family = family;<br /> break;<br /><br /> default:<br /> throw ODataErrors.CreatingLinkNotSupported(Request, navigationProperty);<br /> }<br /> _db.SaveChanges();<br /><br /> return Request.CreateResponse(HttpStatusCode.NoContent);<br /> }

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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