使用复杂类型映射POCO对象,并返回错误3004 [英] Mapping POCO objects with complex types, and error 3004
问题描述
我们有一个医疗应用程序从两个数据库,我们自己的数据库和第三方数据库获取数据。 两个数据库都有一个"患者"表。 我们数据库中的患者表具有列'first_name','middle_name','last_name'和'name_suffix'
(适用于Sr.,Jr。等)。 但是,第三方数据库中的患者表仅包含"first_name","middle_name"和"last_name"列。 没有后缀列。
我们有一个名为 Patient的POCO类,用于来自任一数据库的患者数据。 它看起来像这样:
public class 患者
{
public int Id {获得跨度>; set ; }
public PersonName Name { get ; set ; }
public DateTime Birthdate { get ; set ; }
//等(更多属性)
}
Name属性是一个名为PersonName的复杂类型:
public 类 PersonName
{
public String First { get < /跨度>; set ; }
public String Middle { get ; set ; }
public String Last { get ; set ; }
public 字符串后缀{ get ; set ; }
}
这在EF中是不可能的。有关详细信息,请参阅以下帖子。 http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/294fdabc-fb8c-44a2-b3fd-4df30a868af4
We have a medical application that gets its data from two database, our own, and a third-party database. Both databases have a 'patient' table. The patient table in our database has columns 'first_name', 'middle_name', 'last_name' and 'name_suffix' (for Sr., Jr., etc). However, the patient table in the third-party database has columns only 'first_name', 'middle_name' and 'last_name' columns. There is no suffix column.
We have a POCO class called Patient which is used for patient data from either database. It looks like this:
public class Patient { public int Id { get; set; } public PersonName Name { get; set; } public DateTime Birthdate { get; set; } // etc. (more properties) }
The Name property is a complex type called PersonName:
public class PersonName { public String First { get; set; } public String Middle { get; set; } public String Last { get; set; } public String Suffix { get; set; } }
This is not possible in EF. Please refer the following post for more details. http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/294fdabc-fb8c-44a2-b3fd-4df30a868af4
这篇关于使用复杂类型映射POCO对象,并返回错误3004的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!