我正在学习 asp.net MVC。使用 Code First 模型,您可以在其中创建类,然后使用 EF 管理所有数据库交互。
无论如何只使用这种方法从给定表中请求一些字段,并且只更新这些字段?
我的整个班级是:
Public Class Employee
Public Property ID() As Integer
<DisplayName("Staff Name")>
<Required()>
Public Property StaffName() As String
<DisplayName("Location")>
<Required()>
Public Property Location() As String
<Required()>
<DisplayName("Team Leader")>
Public Property teamleader() As String
Public Property ScoreCardM1() As Integer
Public Property ScoreCardM1Notes() As String
Public Property ScoreCardM2() As Integer
Public Property ScoreCardM2Notes() As String
Public Property ScoreCardM3() As Integer
Public Property ScoreCardM3Notes() As String
Public Property ScoreCardM4() As Integer
Public Property ScoreCardM4Notes() As String
Public Property ScoreCardM5() As Integer
Public Property ScoreCardM5Notes() As String
Public Property ScoreCardM6() As Integer
Public Property ScoreCardM6Notes() As String
Public Property ScoreCardTotal() As Integer
Public Property ScoreCardTotalNotes() As String
Public Property ScoreCardM7() As Integer
Public Property ScoreCardM7Notes() As String
Public Property ScoreCardM8() As Integer
Public Property ScoreCardM8Notes() As String
Public Property ScoreCardM9() As Integer
Public Property ScoreCardM9Notes() As String
Public Property ScoreCardQ3Total() As Integer
Public Property ScoreCardQ3TotalNotes() As String
Public Property ScoreCardM10() As Integer
Public Property ScoreCardM10Notes() As String
Public Property ScoreCardM11() As Integer
Public Property ScoreCardM11Notes() As String
Public Property ScoreCardM12() As Integer
Public Property ScoreCardM12Notes() As String
Public Property ScoreCardQ4Total() As Integer
Public Property ScoreCardQ4TotalNotes() As String
Public Property GeneralNotes() As String
End Class
但是,我只想一次显示和编辑一个月:
Public Class Employee
Public Property ID() As Integer
<DisplayName("Staff Name")>
<Required()>
Public Property StaffName() As String
Public Property ScoreCardM1() As Integer
Public Property ScoreCardM1Notes() As String
End Class
我怎样才能最好地做到这一点?我是否设置了另外 12 个类,每个类只包含一个月,或者是否有一种最佳实践方法可以更新数据库行中的字段子集,而不影响其他类?
谢谢你的帮助,
标记