编辑:看起来这在实体框架中被称为“复杂类型”,我看到我如何能够在列上设置名称以在类中包含一次复杂类型,但我不知道如何/如果你可以使用类中包含的多个相同的复杂类型来做到这一点。
http://blogs.msdn.com/b/wriju/archive/2010/07/26/ef4-complex-type.aspx
EntityFramework 4.1 Code First 错误地命名复杂类型列名
由于 Castle ActiveRecord 已经日落,我正在转向 Entity Framework 5,但是我不知道如何实现 Activerecord 的“嵌套属性”概念:
http://docs.castleproject.org/Active%20Record.Mappings.ashx#Nested_5
我已经完成了谷歌搜索,但我不确定“嵌套”是否是 EF 中这个概念的正确术语,如果它甚至存在的话。这是我在 Castle ActiveRecord 中的表格和课程,有人可以为此提供 EF 术语以及如何完成它:
AmaStatementEntity 上的 Address 属性标记为<Nested(ColumnPrefix:="FL")))>
映射到数据库列 FLStreet、FLSuite、FLCity 等。
CREATE TABLE [dbo].[AMA](
--other columns not necessary to discussion removed
[AMAId] [uniqueidentifier] NOT 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,
[PAStreet] [nvarchar](255) NULL,
[PASuite] [nvarchar](255) NULL,
[PACity] [nvarchar](255) NULL,
[PAZipCode] [nvarchar](255) NULL,
[PACountry] [nvarchar](255) NULL,
[PAState] [nvarchar](255) NULL,
[IAStreet] [nvarchar](255) NULL,
[IASuite] [nvarchar](255) NULL,
[IACity] [nvarchar](255) NULL,
[IAZipCode] [nvarchar](255) NULL,
[IACountry] [nvarchar](255) NULL,
[IAState] [nvarchar](255) NULL,
[EAStreet] [nvarchar](255) NULL,
[EASuite] [nvarchar](255) NULL,
[EACity] [nvarchar](255) NULL,
[EAZipCode] [nvarchar](255) NULL,
[EACountry] [nvarchar](255) NULL,
[EAState] [nvarchar](255) NULL,
[PYAStreet] [nvarchar](255) NULL,
[PYASuite] [nvarchar](255) NULL,
[PYACity] [nvarchar](255) NULL,
[PYAZipCode] [nvarchar](255) NULL,
[PYACountry] [nvarchar](255) NULL,
[PYAState] [nvarchar](255) NULL,
CONSTRAINT [PK_AMA] PRIMARY KEY CLUSTERED
(
[AMAId] ASC
))
Public Class AmaStatementEntity
Public Sub New()
_amaId = Guid.NewGuid
End Sub
'Other properties not relavent to discussion removed
<Nested(ColumnPrefix:="FL")))>
Public Property FacilityLocation() As AddressEntity
<Nested(ColumnPrefix:="BA"))>
Public Property BillingAddress() As AddressEntity
<Nested(ColumnPrefix:="PA"))>
Public Property PatientAddress() As AddressEntity
<Nested(ColumnPrefix:="IA"))>
Public Property InsuredAddress() As AddressEntity
<Nested(ColumnPrefix:="EA"))>
Public Property EmployerAddress() As AddressEntity
<Nested(ColumnPrefix:="PYA"))>
Public Property PayorAddress() As AddressEntity
Public Property AMAId() As Guid
End Class
Public Class AddressEntity
Public Property Street() As String
Public Property Suite() As String
Public Property City() As String
Public Property State() As String
Public Property ZipCode() As String
Public Property Country() As String
Public Property AddressId() As Guid
End Class