エンティティを作成するには、Visual Studio のツールボックスからビジネス データ接続 (BDC) デザイナーにエンティティ コントロールを追加します。
モデルにエンティティを追加するには
BDC プロジェクトを作成するか、または既存の BDC プロジェクトを開きます。 詳細については、「ビジネス データ接続モデルを作成する」を参照してください。
ツールボックスで、BusinessDataCatalog グループから、Entity コントロールをデザイナーに追加します。
新しいエンティティがデザイナーに表示されます。 Visual Studio では、プロジェクト内の BDC モデル ファイルの XML に <Entity>
要素を追加します。 Entity 要素の属性の詳細については、Entity に関するページを参照してください。
デザイナーで、エンティティのショートカット メニューを開き、[追加] を選択してから、[識別子] を選択します。
新しい識別子がエンティティに表示されます。
Note
エンティティと識別子の名前は、[プロパティ] ウィンドウで変更できます。
エンティティのフィールドをクラスに定義します。 プロジェクトに新しいクラスを追加するか、またはオブジェクト リレーショナル デザイナー (O/R デザイナー) などの他のツールを使用して作成された既存のクラスを使用できます。 次の例は、Contact という名前のエンティティ クラスを示しています。
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; }
}
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
関連するコンテンツ