0
我有一個遺留系統,我正在處理,而且我遇到了一些特殊的關係。通過傳統系統的非主鍵進行多對多關係
問題是我需要將患者與HL7EPICareMeds關聯......當然,上述關係不起作用。
從表的角度看,這裏是我
病人:
PatientId:INT,PK
ClinicPatientId:VARCHAR ---不是唯一
HL7EPICareMeds:
標識::int,PK
ClinicPatientId:varchar
MedName:varchar
AdminTime:datetime
我應該重複使用Patient表作爲ClinicPatientIDs和PatientId之間的關聯表嗎?
[ActiveRecord]
public class Patient : RecordBase<Patient>
{
[PrimaryKey("PatientId", Generator=PrimaryKeyType.Native)]
public int? Id
{
get { return _id; }
set
{
_id = value;
}
}
[HasAndBelongsToMany(Inverse = true, Lazy = true)]
public IList<HL7EPICareMeds> Meds
{
get { return _meds; }
set { _meds = value; }
}
}
[ActiveRecord]
public class HL7EPICareMeds : RecordBase<HL7EPICareMeds>
{
[PrimaryKey(Generator = PrimaryKeyType.Native)]
public long Id
{
get { return _Id; }
set
{
_Id = value;
}
}
[Property("AdminTime")]
public DateTime? AdministrationTime
{
get { return _AdministrationTime; }
set { _AdministrationTime = value; }
}
[Property(NotNull = true,Update=false,Insert=false),
ValidateLength(0, 20)]
public string ClinicPatientId
{
get { return _ClinicPatientId; }
set
{
_ClinicPatientId = value;
}
}
[Property(NotNull = true),
ValidateLength(0, 255)]
public string MedName
{
get { return _MedName; }
set
{
_MedName = value;
}
}
[HasAndBelongsToMany()]
public Patient Patient
{
get { return _patient; }
set { _patient = value; }
}
}
是不是隻有在一對多關係中可用的property-ref映射?或者也許它用於表繼承? – Marc 2010-08-26 12:50:32