使用 LINQ 添加子值始终为 1
我有表
PatientEligilit 和 患者资格医生专业 和 医生专科
患者资格 具有外键 PatientsEligibilitiesDoctorsSpecialtyID 来自 患者资格医生专业 表
和
PatientsEligbilitiesDoctorsSpecialty 具有外键 DoctorsSpecialtyID 来自 医生专业 表
然后使用VB.NET LINQ:我正在尝试添加子项目(PatientsEligibilitiesDoctorsSpecialty) 给它的父级(PatientEligilit)
,然后我提交更改,
例如:
PatientEligibilityObject.PatientsEligibilitiesDoctorsSpecialties.Add(New PatientsEligibilitiesDoctorsSpecialty With {.DoctorSpecialtyID = si.ID, .RegDate = Date.Now}) PatientEligibilityObject.PatientsEligibilitiesDoctorsSpecialties.Add(PEDS)
HMSData.SubmitChanges()
它运行良好,并以正确的日期将记录保存在数据库中
但
DoctorSpecialtyID
始终保存为值1
I have the Tables
PatientEligibilit
and
PatientsEligibilitiesDoctorsSpecialties
and
DoctorsSpecialties
PatientEligibilit
has foreign key PatientsEligibilitiesDoctorsSpecialtyID from
PatientsEligibilitiesDoctorsSpecialties
table
and
PatientsEligibilitiesDoctorsSpecialty
has foreign key DoctorsSpecialtyID from
DoctorsSpecialties
table
THEN USING VB.NET LINQ: i'm tring to add child item ( PatientsEligibilitiesDoctorsSpecialty)
to it's parent (PatientEligibilit)
then I submit Changes
like :
PatientEligibilityObject.PatientsEligibilitiesDoctorsSpecialties.Add(New PatientsEligibilitiesDoctorsSpecialty With {.DoctorSpecialtyID = si.ID, .RegDate = Date.Now}) PatientEligibilityObject.PatientsEligibilitiesDoctorsSpecialties.Add(PEDS)
HMSData.SubmitChanges()
it's worked fine and save record in Database with correct date
BUT
DoctorSpecialtyID
always saved with value 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决它。问题出在表之间的关系上。
PatientEligibility 和 PatientsEligbilitiesDoctorsSpecialties 之间的外键
不正确..
I solve it. the problem was in the relation between the tables.
The foreign key between PatientEligibilit and PatientsEligibilitiesDoctorsSpecialties
was not correct..