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);
}
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);
}