将三重连接映射到 nhibernate。 (设计奇怪的旧数据库)
我正在努力将用 powerbuilder 编写的旧应用程序转换为 .NET 应用程序。在此过程中,我们使用旧数据库,并且 powerbuilder 应用程序中使用的一些查询很难转换为 nhibernate 流畅映射(至少对我来说)。
我有以下 sql 来获取位列表:
SELECT MYSCHEME.BIT.BIT_S,
MYSCHEME.BIT.BIT_NAME,
MYSCHEME.BIT.BIT_TYPE,
MYSCHEME.BIT.BIT_SIZE,
MYSCHEME.BS.BS_NAME,
MYSCHEME.CMS.WHOLE_S
FROM MYSCHEME.BIT join MYSCHEME.BS on ( MYSCHEME.BIT.BS_S = MYSCHEME.BS.BS_S )
left outer join MYSCHEME.OF on MYSCHEME.BIT.BIT_TYPE_S = MYSCHEME.OF.F_S
left outer join MYSCHEME.CMS on MYSCHEME.OF.OF_S = MYSCHEME.CMS.PART_S
WHERE ( MYSCHEME.BS.BS_S = 25)
我应该如何将其映射到 nhibernate?我应该使用条件和联接,还是只是将其映射到对其他表的引用?另一个挑战是数据库中的关键约束非常少,例如BIT和OF、CMS和OF之间没有关键约束。
有人知道如何解决这个挑战吗?我还必须能够更新 CMS.WHOLE_S。
第一次加入 BS 表并不是很重要,因为它只是为了获取“父”信息,我可以从应用程序中的其他部分访问该信息。
I am working on converting an old app written in powerbuilder to a .NET app. In this process we work with an old database, and some of the queries used in the powerbuilder app is quite challenging to convert into nhibernate fluent mapping (for me at least).
I have the following sql to get a list of bits:
SELECT MYSCHEME.BIT.BIT_S,
MYSCHEME.BIT.BIT_NAME,
MYSCHEME.BIT.BIT_TYPE,
MYSCHEME.BIT.BIT_SIZE,
MYSCHEME.BS.BS_NAME,
MYSCHEME.CMS.WHOLE_S
FROM MYSCHEME.BIT join MYSCHEME.BS on ( MYSCHEME.BIT.BS_S = MYSCHEME.BS.BS_S )
left outer join MYSCHEME.OF on MYSCHEME.BIT.BIT_TYPE_S = MYSCHEME.OF.F_S
left outer join MYSCHEME.CMS on MYSCHEME.OF.OF_S = MYSCHEME.CMS.PART_S
WHERE ( MYSCHEME.BS.BS_S = 25)
How should i map this into nhibernate? Should i use criteria and joins, or just map it with references to other tables? An other challenge is that there are very few key constrains in the database, for example there is no key constraint between BIT and OF, or CMS and OF.
Anyone has a good idea of how to solve this challenge? I must also be able to update CMS.WHOLE_S.
The first join to the BS table is not very important, since it is only to get the "parent" information, i can access that information from other parts in my application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
奥德
oder