How to join Two tables of two non relashinship defined columns using Nhibernate QueryOver -
using nhibernate queryover
, want join 2 tables using 2 columns not defined in mapping relationship.
e.g. not exact scenario can explain that
tables:
employee(id, name, departmentid, somecode,address) department (id, name, ,code)
select
select * employee e join department d on d.code = e.somecode
can please tell me how query using nhibernate queryover
. note "somecode" in employee
, "code" in department
not defined relationship. departmentid foreign key , can join these using joinalias
want in different way.
there similar questions, e.g.
- nhibernate (+ fluentnhibernate) : join 2 detached tables
- hibernate criteria projection without mapped association of tables
and answer is:
- either use hql , cross join (with where)
- there no way how
queryover
/criteria
)
see doc:
14.2. clause
multiple classes may appear, resulting in cartesian product or "cross" join.
from formula, parameter formula form, parameter param
so using hql in case, can this:
select ... employee e, department d d.code = e.somecode ...
but suggest: create mapping in code. introduce many-to-one
relation. loaded lazily (only if used) , nicely serve our needs - used in queryover
relation join
if there such relation, if exist in business object domain, should not scared use it. can hide via security etc...
Comments
Post a Comment