- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³ã®Entity FrameworkããŒã¿ã¢ãã«ã®äœæ
- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³ã§Entity Frameworkã䜿çšããŠåºæ¬çãªCRUDæ©èœãå®è£ ãã
- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³ã§Entity Frameworkã䜿çšããŠäžŠã¹æ¿ãããã£ã«ã¿ãŒåŠçãããã³ããŒãžåå²ãè¡ã
- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³çšã®è€éãªããŒã¿ã¢ãã«ã®äœæ
- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³ã®è€éãªããŒã¿ã¢ãã«ã®äœæãããŒã2
- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³ã§Entity FrameworkããããŒã¿ãããŒããã
- ASP.NET MVCã¢ããªã±ãŒã·ã§ã³ã§Entity Frameworkã䜿çšããŠé¢é£ããŒã¿ãæŽæ°ãã
åæã¢ã¯ã»ã¹ã®ç«¶å
1人ã®ãŠãŒã¶ãŒã1ã€ã®ãšã³ãã£ãã£ã«é¢ããããŒã¿ã衚瀺ããŠããã«ç·šéããåæã«å¥ã®ãŠãŒã¶ãŒãåãããŒã¿ãæŽæ°ããŠããæåã®ãŠãŒã¶ãŒã«ããå€æŽãããŒã¿ããŒã¹ã«ä¿åããããšãåæã¢ã¯ã»ã¹ã®ç«¶åãçºçããŸãã EFããã®ãããªç«¶åãæ€åºããããã«æ§æãããŠããªãå ŽåãããŒã¿ããŒã¹ãæåŸã«æŽæ°ãããã®ã以åã«è¡ã£ãå€æŽãäžæžãããŸãã å€ãã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ããªã¹ã¯ã¯éèŠã§ã¯ãããŸãããè€æ°ã®ãŠãŒã¶ãŒãè€æ°ã®æŽæ°ããŸãã¯å€æŽã®æžãæããããã»ã©éèŠã§ã¯ãªãå Žåãåæå®è¡æåããã°ã©ãã³ã°ã®ã³ã¹ãã¯ãã®å©ç¹ãããé«ããªããŸãã ãã®å Žåããã®ãããªç¶æ³ãåŠçããããã«ã¢ããªã±ãŒã·ã§ã³ãæ§æããå¿ èŠã¯ãããŸããã
æ²èŠ³ç䞊è¡æ§ïŒããã¯ïŒ
ã¢ããªã±ãŒã·ã§ã³ãåæã¢ã¯ã»ã¹ç«¶åã®çµæãšããŠã®å¶çºçãªããŒã¿æ倱ãé²ãå¿ èŠãããå Žåãåé¡ã解決ããæ¹æ³ã®1ã€ã¯ããŒãã«ãããã¯ããããšã§ãã ããã¯ãæ²èŠ³çåæå®è¡æ§ãšåŒã°ããŸã ã ããšãã°ãããŒã¿ããŒã¹ããã¬ã³ãŒããããŠã³ããŒãããåã«ãèªã¿åãå°çšãŸãã¯æŽæ°ã¢ã¯ã»ã¹ã®ããã¯ãèŠæ±ããŸãã ãã®æ¹æ³ã§å€æŽãžã®ã¢ã¯ã»ã¹ããããã¯ãããšãä»ã®ãŠãŒã¶ãŒã¯ããŒã¿ã®ã³ããŒã®ã¿ãåãåãããããã®ã¬ã³ãŒããèªã¿åãå°çšãããããã¯ããããã¢ã¯ã»ã¹ãå€æŽãããããããšã¯ã§ããŸããã èªã¿åãå°çšã¢ã¯ã»ã¹ãžã®æžã蟌ã¿ã¢ã¯ã»ã¹ããããã¯ãããšãä»ã®ãŠãŒã¶ãŒãèªã¿åãå°çšã¢ã¯ã»ã¹ã«ããã¯ã§ããŸãããå€æŽã¯ã§ããŸããã
ããã¯ç®¡çã«ã¯æ¬ ç¹ããããŸãã ããã°ã©ãã³ã°ã¯è€éãããå¯èœæ§ããããããã¯ã«ã¯æ·±å»ãªããŒã¿ããŒã¹ãªãœãŒã¹ãå¿ èŠã§ãããã¢ããªã±ãŒã·ã§ã³ã®ãŠãŒã¶ãŒæ°ãå¢ãããšããŠã³ããŒãã®ãªãŒããŒããããå¢å ããŸãã ãã®ç¹ã§ããã¹ãŠã®DBMSãæ²èŠ³çåæå®è¡æ§ããµããŒãããŠããããã§ã¯ãããŸããã Entity Frameworkã¯ãæ²èŠ³çãªåæå®è¡æ§ã®çµã¿èŸŒã¿ã¡ã«ããºã ãæäŸããŸããããã®ã¬ãã¹ã³ã§ã¯ããã®ã¢ãããŒãã¯èæ ®ããŸããã
楜芳ç䞊è¡æ§
æ²èŠ³ç䞊è¡æ§ã®ä»£æ¿ã¯ã 楜芳ç䞊è¡æ§ã§ãã 楜芳çåæå®è¡ã«ãããåæã¢ã¯ã»ã¹ã®ç«¶åãçºçããå¯èœæ§ããããŸããããã®ãããªç¶æ³ã«é©åã«å¯Ÿå¿ããããšãã§ããŸãã ããšãã°ãJohnã¯Departments EditããŒãžãéããè±èªãã©ã³ãã®äºç®å€ã350,000.00ãã«ãã100,000.00ãã«ã«å€æŽããŸãã
ãžã§ã³ã[ä¿å]ãã¿ã³ãã¯ãªãã¯ããåã«ããžã§ãŒã³ã¯åãããŒãžãéãã [éå§ æ¥]ã®å€ã1/1/1999ã«å€æŽããŸãã
ãžã§ã³ã¯æåã«[ ä¿å ]ãã¿ã³ãæŒããŠå€æŽã確èªãããã®ç¬éã«ãžã§ãŒã³ããã¿ã³ãæŒããŸãã 以äžã¯ããã®ãããªç¶æ³ãã©ã®ããã«åŠçãããã«äŸåããŸãã 次ã®æ¹æ³ã䜿çšããŠåŠçã§ããŸãã
- ã©ã®ããããã£ãç·šéããããã®èšé²ãä¿æããããŒã¿ããŒã¹å ã®å¯Ÿå¿ããåã®ã¿ãæŽæ°ã§ããŸãã ãã®äŸã§ã¯ãããŸããŸãªããããã£ãããŸããŸãªãŠãŒã¶ãŒã«ãã£ãŠç·šéãããŠãããããããŒã¿ã¯å€±ãããŸããã 次åãè±èªãã©ã³ãã®ããŒã¿ã衚瀺ãããšãããŠãŒã¶ãŒã«ã¯JohnãšJaneã®äž¡æ¹ã«ããå€æŽã衚瀺ãããŸãã
- Janeã®å€æŽã§Johnã®å€æŽãäžæžãã§ããŸãã ãã®åŸã次ã®ãŠãŒã¶ãŒã«ã¯1/1/1999ã衚瀺ãããå€ãå€ã¯$ 350,000.00ã§ãã ãã®ã¹ã¯ãªããã¯ã Client WinsãŸãã¯Last in WinsãšåŒã°ããŸãã ããã¯ãã¢ããªã±ãŒã·ã§ã³ã®åäœãå€æŽããªãå Žåãèªåçã«çºçããŸãã
- ãžã§ãŒã³ã®å€æŽã®ããã«ããŒã¿ããŒã¹ãæŽæ°ããããšã¯ã§ããŸããããšã©ãŒãã¹ããŒããããŒã¿ã®çŸåšã®ç¶æ ã衚瀺ããããŒãžãæŽæ°ããŠãããŒã¿ãåå ¥åããŸãã ãã®ã¹ã¯ãªããã¯Store WinsãšåŒã°ããŸãã ãã®ãã¥ãŒããªã¢ã«ã§ã¯ããã®ã·ããªãªã䜿çšããŸãã å€æŽã倱ãããªãããšãããã³åæã¢ã¯ã»ã¹ã®ç«¶åããŠãŒã¶ãŒã«ã¿ã€ã ãªãŒã«éç¥ãããããšãä¿èšŒãããŸãã
EFã«ãã£ãŠã¹ããŒãããOptimisticConcurrencyExceptionãåŠçããããšã«ããããã®ã¿ã€ãã®ç«¶åã解決ã§ããŸãã ãã®äŸå€ããã€ã¹ããŒããããç¥ãããã«ãEFã¯ç«¶åããã€çºçããããå€æã§ããªããã°ãªããŸããã ãããã£ãŠãããŒã¿ããŒã¹ãšããŒã¿ã¢ãã«ãé©åã«æ§æããå¿ èŠããããŸãã ãã®ã»ããã¢ããã«ã¯ã次ã®ãªãã·ã§ã³ã䜿çšã§ããŸãã
- ããŒã¿ããŒã¹ã®ããŒãã«ã«ãã远跡ãåãå«ããŸãããã®åã¯ãã¬ã³ãŒãããã€å€æŽãããããå€æããããã«äœ¿çšã§ããŸãã ãã®åŸããã®åãæŽæ°ã¯ãšãªãŸãã¯åé€ã¯ãšãªã®Whereå¥ã«å«ããããšãã§ããŸãã
- Updateããã³Deleteã¯ãšãªã®Whereã¹ããŒãã¡ã³ãã«ååã®ãœãŒã¹ããŒã¿ãå«ããããã«EFãæ§æããŸãã
ãã®ã¬ãã¹ã³ã§ã¯ãã远跡ãåãDepartmentãšã³ãã£ãã£ã«è¿œå ããã³ã³ãããŒã©ãŒãšãã¥ãŒãäœæããŠããã¹ãŠãäžç·ã«ãã¹ãããŸãã
ã远跡ãåãªãã§äžŠååŠçãå®è£ ããå Žåããã¹ãŠã®åãæŽæ°ã¯ãšãªã®Whereã¹ããŒãã¡ã³ãã«å«ãŸããããšãEFã«æå®ããŠããã¹ãŠã®éãã©ã€ããªããŒãConcurrencyCheckå±æ§ã§ããŒã¯ããå¿ èŠããããŸãã
éšçœ²ã® ãšã³ãã£ãã£ã«è¿œè·¡åãè¿œå ãã
ã¢ãã« \ éšé ã csã¯ããã©ããã³ã°ãåãè¿œå ããŸãã
[Timestamp] public Byte[] Timestamp { get; set; }
Timestampå±æ§ã¯ããã®åãUpdateããã³Deleteã¯ãšãªã®Whereã¹ããŒãã¡ã³ãã«å«ãŸããããšã決å®ããŸãã
ã³ã³ãããŒã©ãŒ äœæ
éšéã³ã³ãããŒã©ãŒãšãã¥ãŒãäœæããŸãã
Controllers \ DepartmentController.csã§æ¬¡ã䜿çšããŠè¿œå ããŸãã
System.Data.Entity.Infrastructureã䜿çšããŸãã
ãã¡ã€ã«å šäœïŒ4ã€ã®ãšã³ããªïŒã§LastNameãFullNameã«å€æŽããŠãåŠéšç®¡çè ã®ããããããŠã³ãªã¹ãã«å§ã§ã¯ãªããã«ããŒã ã衚瀺ãããããã«ããŸãã
HttpPost Editã¡ãœããã³ãŒãã次ã®ããã«çœ®ãæããŸãã
[HttpPost] public ActionResult Edit(Department department) { try { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } } catch (DbUpdateConcurrencyException ex) { var entry = ex.Entries.Single(); var databaseValues = (Department)entry.GetDatabaseValues().ToObject(); var clientValues = (Department)entry.Entity; if (databaseValues.Name != clientValues.Name) ModelState.AddModelError("Name", "Current value: " + databaseValues.Name); if (databaseValues.Budget != clientValues.Budget) ModelState.AddModelError("Budget", "Current value: " + String.Format("{0:c}", databaseValues.Budget)); if (databaseValues.StartDate != clientValues.StartDate) ModelState.AddModelError("StartDate", "Current value: " + String.Format("{0:d}", databaseValues.StartDate)); if (databaseValues.InstructorID != clientValues.InstructorID) ModelState.AddModelError("InstructorID", "Current value: " + db.Instructors.Find(databaseValues.InstructorID).FullName); ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you got the original value. The " + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again. Otherwise click the Back to List hyperlink."); department.Timestamp = databaseValues.Timestamp; } catch (DataException) { //Log the error (add a variable name after Exception) ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator."); } ViewBag.InstructorID = new SelectList(db.Instructors, "InstructorID", "FullName", department.InstructorID); return View(department); }
ãã¥ãŒã«ã¯ãé衚瀺ãã£ãŒã«ãã«ããã©ããã³ã°ãåã®å ã®å€ã衚瀺ãããŸãã éšéã€ã³ã¹ã¿ã³ã¹ãäœæãããšãããã®ãªããžã§ã¯ãã¯Timestampããããã£ã«å€ãæã¡ãŸããã 次ã«ãEFæŽæ°ãªã¯ãšã¹ããäœæããåŸããªã¯ãšã¹ãã«ã¯ãå ã®ã¿ã€ã ã¹ã¿ã³ãå€ãæã€ã¬ã³ãŒãã®æ€çŽ¢æ¡ä»¶ãå«ãWhereã¹ããŒãã¡ã³ããå«ãŸããŸãã
UpdateèŠæ±ã§æŽæ°ãæŽæ°ãããªãå ŽåãEFã¯DbUpdateConcurrencyExceptionãã¹ããŒããcatchãããã¯ã®ã³ãŒãã¯äŸå€ã«é¢é£ä»ããããDepartmentãšã³ãã£ãã£ãè¿ããŸãã ãã®ãšã³ãã£ãã£ã«ã¯ãå ã®ããããã£å€ãšæ°ããããããã£å€ããããŸãã
var entry = ex.Entries.Single(); var databaseValues = (Department)entry.GetDatabaseValues().ToObject(); var clientValues = (Department)entry.Entity;
ããã«ãã³ãŒãã¯ããŠãŒã¶ãŒãç·šéããŒãžã§å ¥åããå€ãšã¯ç°ãªãããŒã¿ããŒã¹å ã®å€ãæã€ååã«ãšã©ãŒã¡ãã»ãŒãžãè¿œå ããŸãã
if (databaseValues.Name != currentValues.Name) ModelState.AddModelError("Name", "Current value: " + databaseValues.Name); // ...
ãšã©ãŒã®å Žåã詳现ãªã¡ãã»ãŒãžã衚瀺ãããŸãã
ModelState.AddModelError(string.Empty, "The record you attempted to edit " + "was modified by another user after you got the original value. The" + "edit operation was canceled and the current values in the database " + "have been displayed. If you still want to edit this record, click " + "the Save button again. Otherwise click the Back to List hyperlink.");
æåŸã«ãã³ãŒãã¯Departmentãªããžã§ã¯ãã®Timestampããããã£ã®å€ãããŒã¿ããŒã¹ããååŸããæ°ããå€ã«èšå®ããŸãã ãã®æ°ããå€ã¯ã[ç·šé]ããŒãžãæŽæ°ããããšé衚瀺ãã£ãŒã«ãã«ä¿åããã次å[ä¿å]ãã¯ãªãã¯ãããšãããŒãžã®åèªã¿èŸŒã¿åŸã«çºçããåæå®è¡ãšã©ãŒã®ã¿ããã£ãããããŸãã
ãã¥ãŒ \ éšé \ ç·šé㧠ã cshtmlã¯ãDepartmentIDããããã£ã®é衚瀺ãã£ãŒã«ãã®çŽåŸã«ãé衚瀺ãã£ãŒã«ããè¿œå ããŠã¿ã€ã ã¹ã¿ã³ãå€ãä¿åããŸãã
Html .HiddenForïŒmodel => model.TimestampïŒ
ãã¥ãŒ \ éšé \ ã€ã³ããã¯ã¹ã§ ã cshtmlã¯ã³ãŒãã眮ãæããŠããšã³ããªãªã³ã¯ãå·Šã«ç§»åããããŒãžããããŒãšåãå€æŽããŸãã
@model IEnumerable<ContosoUniversity.Models.Department> @{ ViewBag.Title = "Departments"; } <h2>Departments</h2> <p> @Html.ActionLink("Create New", "Create") </p> <table> <tr> <th></th> <th>Name</th> <th>Budget</th> <th>Start Date</th> <th>Administrator</th> </tr> @foreach (var item in Model) { <tr> <td> @Html.ActionLink("Edit", "Edit", new { id=item.DepartmentID }) | @Html.ActionLink("Details", "Details", new { id=item.DepartmentID }) | @Html.ActionLink("Delete", "Delete", new { id=item.DepartmentID }) </td> <td> @Html.DisplayFor(modelItem => item.Name) </td> <td> @Html.DisplayFor(modelItem => item.Budget) </td> <td> @Html.DisplayFor(modelItem => item.StartDate) </td> <td> @Html.DisplayFor(modelItem => item.Administrator.FullName) </td> </tr> } </table>
楜芳çåæå®è¡ã®ãã¹ã
ãããžã§ã¯ããå®è¡ãã Departmentsãã¯ãªãã¯ããŸãã
[ ç·šé]ãªã³ã¯ãã¯ãªãã¯ããå¥ã®ãã©ãŠã¶ãŠã£ã³ããŠã§å¥ã®ç·šéããŒãžãéããŸãã Windowsã¯åäžã®æ å ±ã衚瀺ããã¯ãã§ãã
æåã®ãã©ãŠã¶ãŠã£ã³ããŠã§ãã£ãŒã«ããå€æŽãã[ ä¿å ]ãã¯ãªãã¯ããŸã ã
å€æŽãããããŒã¿ãå«ãã€ã³ããã¯ã¹ããŒãžã衚瀺ãããŸãã
2çªç®ã®ãã©ãŠã¶ãŠã£ã³ããŠã§åããã£ãŒã«ããå¥ã®å€ã«å€æŽããŸãã
[ ä¿å]ãã¯ãªãã¯ããŠããšã©ãŒã¡ãã»ãŒãžã衚瀺ããŸãã
[ ä¿å]ãããäžåºŠã¯ãªãã¯ããŸã ã 2çªç®ã®ãã©ãŠã¶ãŒãŠã£ã³ããŠã«å ¥åããå€ã¯ããŒã¿ããŒã¹ã«ä¿åãããå€æŽã[ã€ã³ããã¯ã¹]ããŒãžã«è¡šç€ºãããããšãããããŸãã
åé€ããŒãžã®è¿œå
åé€ããŒãžã®å Žåãåæå®è¡ã®åé¡ã¯åæ§ã«åŠçãããŸãã HttpGet Deleteã¡ãœããã«ãã£ãŠç¢ºèªãŠã£ã³ããŠã衚瀺ããããšããã¥ãŒã®é衚瀺ãã£ãŒã«ãã«å ã®ã¿ã€ã ã¹ã¿ã³ãå€ãå«ãŸããŸãã ãã®å€ã¯ããŠãŒã¶ãŒãåé€ã確èªãããšãã«åŒã³åºãããHttpPost Deleteã¡ãœããã§äœ¿çšã§ããŸãã EFãåé€èŠæ±ãäœæããå Žåããã®èŠæ±ã«ã¯å ã®ã¿ã€ã ã¹ã¿ã³ãå€ãå«ãWhereã¹ããŒãã¡ã³ããå«ãŸããŸãã ãªã¯ãšã¹ããäœãè¿ããªãå Žåã¯ãåæå®è¡äŸå€ãã¹ããŒããããšã©ãŒãã©ã¡ãŒã¿ãtrueã«èšå®ããŠHttpGet Deleteã¡ãœãããåŒã³åºããããšã©ãŒã¡ãã»ãŒãžãå«ã確èªããŒãžãåããŒããããŸãã
DepartmentController㧠ã csã¯ãHttpGet Deleteã¡ãœããã®ã³ãŒãã次ã®ããã«çœ®ãæããŸãã
public ActionResult Delete(int id, bool? concurrencyError) { if (concurrencyError.GetValueOrDefault()) { ViewBag.ConcurrencyErrorMessage = "The record you attempted to delete " + "was modified by another user after you got the original values. " + "The delete operation was canceled and the current values in the " + "database have been displayed. If you still want to delete this " + "record, click the Delete button again. Otherwise " + "click the Back to List hyperlink."; } Department department = db.Departments.Find(id); return View(department); }
ãã®ã¡ãœããã¯ãåæå®è¡ãšã©ãŒã®åŸã«ããŒãžããªããŒããããã©ããã決å®ãããªãã·ã§ã³ã®ãã©ã¡ãŒã¿ãŒãåãå ¥ããŸãã trueã«èšå®ãããŠããå Žåããšã©ãŒã¡ãã»ãŒãžã¯ViewBagããããã£ã®ãã¥ãŒã«éä¿¡ãããŸãã
HttpPost DeleteïŒDeleteConfirmedïŒã¡ãœããã³ãŒãã次ã®ã³ãŒãã«çœ®ãæããŸãã
[HttpPost, ActionName("Delete")] public ActionResult DeleteConfirmed(Department department) { try { db.Entry(department).State = EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Index"); } catch (DbUpdateConcurrencyException) { return RedirectToAction("Delete", new System.Web.Routing.RouteValueDictionary { { "concurrencyError", true } }); } catch (DataException) { //Log the error (add a variable name after Exception) ModelState.AddModelError(string.Empty, "Unable to save changes. Try again, and if the problem persists contact your system administrator."); return View(department); } }
æåã¯ãã¡ãœããã¯ã¬ã³ãŒãIDã®å€ã®ã¿ãåãå ¥ããŸããã
ãããªãã¯ActionResult DeleteConfirmedïŒint idïŒ
ãã®ãã©ã¡ãŒã¿ãŒãDepartmentãšã³ãã£ãã£ã«å€æŽãããšãTimestampããããã£ã«ã¢ã¯ã»ã¹ã§ããŸãã
ãããªãã¯ActionResult DeleteConfirmedïŒéšéïŒ
åæå®è¡ãšã©ãŒãã¹ããŒãããå Žåãã³ãŒãã¯ãšã©ãŒãã©ã¡ãŒã¿ãŒãèšå®ããã確èªããŒãžããªããŒãããŸãã
ãã¥ãŒ \ éšé \ åé€ã§ ã cshtmlã¯ããšã©ãŒã¡ãã»ãŒãžã®ãã©ãŒããããšãã£ãŒã«ããæäŸããã³ãŒãã§ã³ãŒãã眮ãæããŸãã
@model ContosoUniversity.Models.Department @{ ViewBag.Title = "Delete"; } <h2>Delete</h2> <p class="error">@ViewBag.ConcurrencyErrorMessage</p> <h3>Are you sure you want to delete this?</h3> <fieldset> <legend>Department</legend> <div class="display-label"> @Html.LabelFor(model => model.Name) </div> <div class="display-field"> @Html.DisplayFor(model => model.Name) </div> <div class="display-label"> @Html.LabelFor(model => model.Budget) </div> <div class="display-field"> @Html.DisplayFor(model => model.Budget) </div> <div class="display-label"> @Html.LabelFor(model => model.StartDate) </div> <div class="display-field"> @Html.DisplayFor(model => model.StartDate) </div> <div class="display-label"> @Html.LabelFor(model => model.InstructorID) </div> <div class="display-field"> @Html.DisplayFor(model => model.Administrator.FullName) </div> </fieldset> @using (Html.BeginForm()) { @Html.HiddenFor(model => model.DepartmentID) @Html.HiddenFor(model => model.Timestamp) <p> <input type="submit" value="Delete" /> | @Html.ActionLink("Back to List", "Index") </p> }
ãã®ã³ãŒãã¯ãh2ããããŒãšh3ããããŒã®éã«ãšã©ãŒã¡ãã»ãŒãžãè¿œå ããŸãã
<p class = "error"> @ ViewBag.ConcurrencyErrorMessage </ p>
Administratorãã£ãŒã«ãã®LastNameãFullNameã«çœ®ãæããŸãã
<div class="display-label"> @Html.LabelFor(model => model.InstructorID) </div> <div class="display-field"> @Html.DisplayFor(model => model.Administrator.FullName) </div>
æåŸã«ãDepartmentIDãšTimestampã®é衚瀺ãã£ãŒã«ããè¿œå ãããŸãã
@Html.HiddenFor(model => model.DepartmentID) @Html.HiddenFor(model => model.Timestamp)
å¥ã®ãã©ãŠã¶ãŠã£ã³ããŠã§éšéã€ã³ããã¯ã¹ããŒãžãéããŸãã
æåã®ãŠã£ã³ããŠã§ã[ ç·šé ]ãã¯ãªãã¯ããŠããããã®å€ãå€æŽããŸããã[ ä¿å ]ãã¯ãªãã¯ããªãã§ãã ããã
2çªç®ã®ãŠã£ã³ããŠã§ãåãåŠéšã®[åé€]ãã¯ãªãã¯ããŸãã 確èªãŠã£ã³ããŠã衚瀺ãããŸãã
æåã®ãã©ãŠã¶ãŠã£ã³ããŠã§[ ä¿å]ãã¯ãªãã¯ããŸã ã å€æŽã確èªãããŸãã
次ã«ã2çªç®ã®ãã©ãŠã¶ãŒãŠã£ã³ããŠã§[åé€]ãã¯ãªãã¯ããŠãåæå®è¡ãšã©ãŒã¡ãã»ãŒãžã衚瀺ããŸãã ããŒã¿ãæŽæ°ãããŸãã
ããäžåºŠ[åé€]ãã¯ãªãã¯ãããšãæå¡ã®ãšã³ããªãåé€ãããããšã確èªããã€ã³ããã¯ã¹ããŒãžãéããŸãã
åæã¢ã¯ã»ã¹ç«¶åã®å°å ¥ãå®äºããŸããã 詳现ã«ã€ããŠã¯ã 楜芳çåæå®è¡ãã¿ãŒã³ãšããããã£å€ã®æäœãåç §ããŠãã ããã 次ã®ã¬ãã¹ã³ã§ã¯ããšã³ãã£ãã£InstructorãšStudentã®ç¶æ¿ãå®è£ ããæ¹æ³ã瀺ããŸãã
è¬èŸ
Alexander Belotserkovskyã®ç¿»èš³ã«ãååããã ãããããšãããããŸãã