-1

asp.net mvc アプリで .Net 用の Neo4j 公式ドライバーを使用して、モデルの値を更新したいと考えています。私のコードは次のとおりです。

[HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Edit(string name, Category category)
    {
        try
        {
            var oldName = name.ToString();
            var newName = category.Name.ToString();
            using (var session = _driver.Session())
            {
                session.WriteTransaction(tx =>
                {
                    tx.Run("Match (a:Category) WHERE a.Name = '$oldName' Set a.Name = '$newName'", new { oldName, newName });
                });
            }

            return RedirectToAction(nameof(Index));
        }
        catch
        {
            return View();
        }
    }

しかし、コードは変更されません。なんで?

モデルクラス:

 public class Category
{
    public string Name { get; set; }
}

そしてname、View で次のコードから値を取得します。

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { name = item.Name/* id=item.PrimaryKey */ }) |
            @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
            @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
        </td>
    </tr>
}
4

1 に答える 1