简体   繁体   English

nhibernate联接,表之间没有关系

[英]nhibernate joins with no relationship between tables

tableA
------
Aprimarykey,
Afield1,
Afield2,
AfieldtoMatch  

tableB
------
Bprimarykey,
Bfield1,
Bfield2,
BfieldtoMatch   

There is no relationship between tables. 表之间没有关系。 What would be the classes and the hbm file look like if I want the following results? 如果我想要以下结果,这些类和hbm文件将是什么样的?

select distinct tableA.Afield1, tableA.Afield2,tableA.AfieldMatch tableB.Bfield1,tableB.Bfield1    
from tableA innerjoin tableB on tableA.AfieldtoMatch=tableB.Bmatchfield

Since you want to join, clearly there is some sort of relationship, though abstract. 因为您想加入,所以显然存在某种关系,尽管很抽象。

Stating an SQL query as the intended results leaves the question still open for interpretation. 将SQL查询声明为预期结果会使问题仍然可以解释。 You should probably map the tables each to separate entities, then you can use HQL or LINQ to join on arbitrary columns when you query. 您可能应该将每个表映射到单独的实体,然后在查询时可以使用HQL或LINQ联接任意列。

You might also want to look at the <join> element in the reference: http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-join . 您可能还需要查看参考资料中的<join>元素: http : //nhibernate.info/doc/nh/en/index.html#mapping-declaration-join

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM