HOW TO:將實體加入至模型
若要建立實體,請將實體從 Visual Studio 的 [工具箱] 拖曳至商務資料連接 (BDC) 設計工具上。
若要在模型中新增實體
建立 BDC 專案或開啟現有的 BDC 專案。 如需詳細資訊,請參閱建立商務資料連接模型。
在 [工具箱] 中,將實體從 [BusinessDataCatalog] 群組拖曳至設計工具。
新實體隨即出現在設計工具中。 Visual Studio 會將 <Entity> 項目新增至專案內 BDC 模型檔案的 XML。 如需 Entity 項目屬性的詳細資訊,請參閱 Entity (英文)。
在設計工具中,以滑鼠右鍵按一下實體,再按一下 [加入],然後按一下 [識別項]。
新識別項隨即出現在實體上。
注意事項
您可以在 [屬性視窗] 中變更實體名稱和識別項。
在類別中定義實體的欄位。 您可以使用物件關聯式設計工具 (O/R 設計工具) 等其他工具將新類別加入至專案,也可以使用現有的類別。 下列範例顯示名為 Contact 的實體類別。
Partial Public Class Contact Private _ContactID As Integer Public Property ContactID() As Integer Get Return _ContactID End Get Set(ByVal value As Integer) _ContactID = value End Set End Property Private _FirstName As String Public Property FirstName() As String Get Return _FirstName End Get Set(ByVal value As String) _FirstName = value End Set End Property Private _LastName As String Public Property LastName() As String Get Return _LastName End Get Set(ByVal value As String) _LastName = value End Set End Property Private _EmailAddress As String Public Property EmailAddress() As String Get Return _EmailAddress End Get Set(ByVal value As String) _EmailAddress = value End Set End Property Private _Phone As String Public Property Phone() As String Get Return _Phone End Get Set(ByVal value As String) _Phone = value End Set End Property Private _EmailPromotion As Integer Public Property EmailPromotion() As Integer Get Return _EmailPromotion End Get Set(ByVal value As Integer) _EmailPromotion = value End Set End Property Private _NameStyle As Boolean Public Property NameStyle() As Boolean Get Return _NameStyle End Get Set(ByVal value As Boolean) _NameStyle = value End Set End Property Private _PasswordHash As String Public Property PasswordHash() As String Get Return _PasswordHash End Get Set(ByVal value As String) _PasswordHash = value End Set End Property Private _PasswordSalt As String Public Property PasswordSalt() As String Get Return _PasswordSalt End Get Set(ByVal value As String) _PasswordSalt = value End Set End Property End Class
public partial class Contact { public int ContactID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string EmailAddress { get; set; } public string Phone { get; set; } public int EmailPromotion { get; set; } public bool NameStyle { get; set; } public string PasswordHash { get; set; } public string PasswordSalt { get; set; } }