クラス定義
Public Class AddressEntity
Private _addressId As Guid
Private m_strStreet As String
Private m_strSuite As String
Private m_strCity As String
Private m_State As String
Private m_strZipCode As String
Private m_strCountry As String
Public Overridable Property Street() As String
Get
Return m_strStreet
End Get
Set(ByVal Value As String)
m_strStreet = Left(Value, 50)
DataChanged(EntityState.Modified, "Street")
End Set
End Property
Public Overridable Property Suite() As String
Get
Return m_strSuite
End Get
Set(ByVal Value As String)
m_strSuite = Left(Value, 50)
DataChanged(EntityState.Modified, "Suite")
End Set
End Property
Public Overridable Property City() As String
Get
Return m_strCity
End Get
Set(ByVal Value As String)
m_strCity = Left(Value, 50)
DataChanged(EntityState.Modified, "City")
End Set
End Property
Public Overridable Property State() As String
Get
Return m_State
End Get
Set(ByVal Value As String)
m_State = Left(Value, 50)
DataChanged(EntityState.Modified, "State")
End Set
End Property
<MaxStringLength(10)>
Public Overridable Property ZipCode() As String
Get
Return m_strZipCode
End Get
Set(ByVal Value As String)
m_strZipCode = Left(Value, 10)
DataChanged(EntityState.Modified, "ZipCode")
End Set
End Property
Public Overridable Property Country() As String
Get
Return m_strCountry
End Get
Set(ByVal Value As String)
m_strCountry = Left(Value, 50)
DataChanged(EntityState.Modified, "Country")
End Set
End Property
<Key>
Public Overridable Property AddressId() As Guid
Get
Return _addressId
End Get
Set(ByVal value As Guid)
_addressId = value
End Set
End Property
Public Class AMAStatementEntity
Private _DateOfService As Nullable(Of DateTime)
Private _FacilityLocation As AddressEntity
Private _BillingAddress As AddressEntity
<Key>
Public Property AMAId() As Guid
Get
Return _amaId
End Get
Set(ByVal value As Guid)
_amaId = value
End Set
End Property
Public Property DateOfService() As Nullable(Of Date)
Get
Return _DateOfService
End Get
Set(ByVal value As Nullable(Of Date))
_DateOfService = value
End Set
End Property
'This was used in Castle Activerecord
'<Nested(ColumnPrefix:="FL")> _
Public Property FacilityLocation() As AddressEntity
Get
Return _FacilityLocation
End Get
Set(ByVal value As AddressEntity)
_FacilityLocation = value
End Set
End Property
'This was used in Castle Activerecord
'<Nested(ColumnPrefix:="BA")> _
Public Property BillingAddress() As AddressEntity
Get
Return _BillingAddress
End Get
Set(ByVal value As AddressEntity)
_BillingAddress = value
End Set
End Property
'Other irrelevant properties cut for brevity.
End Class
データベース テーブル
CREATE TABLE [dbo].[AMA](
[AMAId] [uniqueidentifier] NOT NULL,
[DateOfService] [datetime] NULL,
[FLStreet] [nvarchar](255) NULL,
[FLSuite] [nvarchar](255) NULL,
[FLCity] [nvarchar](255) NULL,
[FLZipCode] [nvarchar](255) NULL,
[FLCountry] [nvarchar](255) NULL,
[FLState] [nvarchar](255) NULL,
[BAStreet] [nvarchar](255) NULL,
[BASuite] [nvarchar](255) NULL,
[BACity] [nvarchar](255) NULL,
[BAZipCode] [nvarchar](255) NULL,
[BACountry] [nvarchar](255) NULL,
[BAState] [nvarchar](255) NULL,
CONSTRAINT [PK_AMA] PRIMARY KEY CLUSTERED
(
[AMAId] ASC
)
) ON [PRIMARY]
上記のクラスとテーブル構造が与えられた場合、これらのクラスがデータベースにどのように格納されているかを Entity Framework に正しく伝えるにはどうすればよいでしょうか? 私は、ネストされた属性を使用し、オプション列のプレフィックスを持つ Castle ActiveRecord (NHibernate の上にある) から移行しています。また、この構成体の正しい名前 (存在する場合) はわかりません。TPT、TPC、および TPH については知っていますが、この名前は見つかりませんでした。