我在下面粘貼了一些代碼。你還在找什麼?我更喜歡Fluent API方法。我喜歡使用這個工具:
http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
這裏是C#
public partial class Grade
{
public Grade()
{
this.Students = new List<Student>();
this.Teachers = new List<Teacher>();
}
public int GradeID { get; set; }
public string Name { get; set; }
public virtual ICollection<Student> Students { get; set; }
public virtual ICollection<Teacher> Teachers { get; set; }
}
下面的代碼是在VB代碼
Public Partial Class Grade
Public Sub New()
Me.Students = New List(Of Student)()
Me.Teachers = New List(Of Teacher)()
End Sub
Public Property GradeID() As Integer
Get
Return m_GradeID
End Get
Set
m_GradeID = Value
End Set
End Property
Private m_GradeID As Integer
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Name As String
Public Overridable Property Students() As ICollection(Of Student)
Get
Return m_Students
End Get
Set
m_Students = Value
End Set
End Property
Private Overridable m_Students As ICollection(Of Student)
Public Overridable Property Teachers() As ICollection(Of Teacher)
Get
Return m_Teachers
End Get
Set
m_Teachers = Value
End Set
End Property
Private Overridable m_Teachers As ICollection(Of Teacher)
末級
我會努力今天爲您發佈一些示例代碼。我建議切換到C#我曾經在VB代碼,但我強迫自己切換,並享受C#更好。 – VoltaicShock
非常感謝!實際上掌握c#是我10年的計劃。 – user3313436