Asp.Net MVC Create/Update/Delete with composite key
- by nubm
Hi, I'm not sure how to use composite key.
My Categories table has CategoryId (PK,FK), LanguageId (PK,FK), CategoryName
CategoryId | LanguageId | CategoryName
1 | 1 | Car
1 | 2 | Auto
1 | 3 | Automobile
etc.
I'm following this design
The default action looks like
//
// GET: /Category/Edit/5
public ActionResult Edit(int id)
{
return View();
}
and ActionLink
<%= Html.ActionLink("Edit", "Edit", new { id= item.CategoryId }) %>
Should I use something like
<%= Html.ActionLink("Edit", "Edit", new { id= (item.CategoryId + "-" + item.LanguageId) }) %>
so the url is
/Category/Edit/5-5
and
//
// GET: /Category/Edit/5-5
public ActionResult Edit(string id)
{
// parse id
return View();
}
or change the route to something like
/Category/Edit/5/5
Or there is some better way?