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.

and answer is:

  1. either use hql , cross join (with where)
  2. 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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -